documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. 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);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * 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)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * 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
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * 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"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * 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".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * 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"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * 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".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** 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 */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** 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 */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** 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 */
  4090. static readonly GEQUAL: number;
  4091. /** 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 */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * 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.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. 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;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** 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 */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areAttributesDirty: boolean;
  7614. /** @hidden */
  7615. _areTexturesDirty: boolean;
  7616. /** @hidden */
  7617. _areFresnelDirty: boolean;
  7618. /** @hidden */
  7619. _areMiscDirty: boolean;
  7620. /** @hidden */
  7621. _areImageProcessingDirty: boolean;
  7622. /** @hidden */
  7623. _normals: boolean;
  7624. /** @hidden */
  7625. _uvs: boolean;
  7626. /** @hidden */
  7627. _needNormals: boolean;
  7628. /** @hidden */
  7629. _needUVs: boolean;
  7630. [id: string]: any;
  7631. /**
  7632. * Specifies if the material needs to be re-calculated
  7633. */
  7634. readonly isDirty: boolean;
  7635. /**
  7636. * Marks the material to indicate that it has been re-calculated
  7637. */
  7638. markAsProcessed(): void;
  7639. /**
  7640. * Marks the material to indicate that it needs to be re-calculated
  7641. */
  7642. markAsUnprocessed(): void;
  7643. /**
  7644. * Marks the material to indicate all of its defines need to be re-calculated
  7645. */
  7646. markAllAsDirty(): void;
  7647. /**
  7648. * Marks the material to indicate that image processing needs to be re-calculated
  7649. */
  7650. markAsImageProcessingDirty(): void;
  7651. /**
  7652. * Marks the material to indicate the lights need to be re-calculated
  7653. */
  7654. markAsLightDirty(): void;
  7655. /**
  7656. * Marks the attribute state as changed
  7657. */
  7658. markAsAttributesDirty(): void;
  7659. /**
  7660. * Marks the texture state as changed
  7661. */
  7662. markAsTexturesDirty(): void;
  7663. /**
  7664. * Marks the fresnel state as changed
  7665. */
  7666. markAsFresnelDirty(): void;
  7667. /**
  7668. * Marks the misc state as changed
  7669. */
  7670. markAsMiscDirty(): void;
  7671. /**
  7672. * Rebuilds the material defines
  7673. */
  7674. rebuild(): void;
  7675. /**
  7676. * Specifies if two material defines are equal
  7677. * @param other - A material define instance to compare to
  7678. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7679. */
  7680. isEqual(other: MaterialDefines): boolean;
  7681. /**
  7682. * Clones this instance's defines to another instance
  7683. * @param other - material defines to clone values to
  7684. */
  7685. cloneTo(other: MaterialDefines): void;
  7686. /**
  7687. * Resets the material define values
  7688. */
  7689. reset(): void;
  7690. /**
  7691. * Converts the material define values to a string
  7692. * @returns - String of material define information
  7693. */
  7694. toString(): string;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7701. * 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;
  7702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7703. */
  7704. export class ColorCurves {
  7705. private _dirty;
  7706. private _tempColor;
  7707. private _globalCurve;
  7708. private _highlightsCurve;
  7709. private _midtonesCurve;
  7710. private _shadowsCurve;
  7711. private _positiveCurve;
  7712. private _negativeCurve;
  7713. private _globalHue;
  7714. private _globalDensity;
  7715. private _globalSaturation;
  7716. private _globalExposure;
  7717. /**
  7718. * Gets the global Hue value.
  7719. * 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).
  7720. */
  7721. /**
  7722. * Sets the global Hue value.
  7723. * 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).
  7724. */
  7725. globalHue: number;
  7726. /**
  7727. * Gets the global Density value.
  7728. * 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.
  7729. * Values less than zero provide a filter of opposite hue.
  7730. */
  7731. /**
  7732. * Sets the global Density value.
  7733. * 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.
  7734. * Values less than zero provide a filter of opposite hue.
  7735. */
  7736. globalDensity: number;
  7737. /**
  7738. * Gets the global Saturation value.
  7739. * 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.
  7740. */
  7741. /**
  7742. * Sets the global Saturation value.
  7743. * 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.
  7744. */
  7745. globalSaturation: number;
  7746. /**
  7747. * Gets the global Exposure value.
  7748. * 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.
  7749. */
  7750. /**
  7751. * Sets the global Exposure value.
  7752. * 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.
  7753. */
  7754. globalExposure: number;
  7755. private _highlightsHue;
  7756. private _highlightsDensity;
  7757. private _highlightsSaturation;
  7758. private _highlightsExposure;
  7759. /**
  7760. * Gets the highlights Hue value.
  7761. * 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).
  7762. */
  7763. /**
  7764. * Sets the highlights Hue value.
  7765. * 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).
  7766. */
  7767. highlightsHue: number;
  7768. /**
  7769. * Gets the highlights Density value.
  7770. * 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.
  7771. * Values less than zero provide a filter of opposite hue.
  7772. */
  7773. /**
  7774. * Sets the highlights Density value.
  7775. * 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.
  7776. * Values less than zero provide a filter of opposite hue.
  7777. */
  7778. highlightsDensity: number;
  7779. /**
  7780. * Gets the highlights Saturation value.
  7781. * 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.
  7782. */
  7783. /**
  7784. * Sets the highlights Saturation value.
  7785. * 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.
  7786. */
  7787. highlightsSaturation: number;
  7788. /**
  7789. * Gets the highlights Exposure value.
  7790. * 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.
  7791. */
  7792. /**
  7793. * Sets the highlights Exposure value.
  7794. * 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.
  7795. */
  7796. highlightsExposure: number;
  7797. private _midtonesHue;
  7798. private _midtonesDensity;
  7799. private _midtonesSaturation;
  7800. private _midtonesExposure;
  7801. /**
  7802. * Gets the midtones Hue value.
  7803. * 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).
  7804. */
  7805. /**
  7806. * Sets the midtones Hue value.
  7807. * 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).
  7808. */
  7809. midtonesHue: number;
  7810. /**
  7811. * Gets the midtones Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. /**
  7816. * Sets the midtones Density value.
  7817. * 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.
  7818. * Values less than zero provide a filter of opposite hue.
  7819. */
  7820. midtonesDensity: number;
  7821. /**
  7822. * Gets the midtones Saturation value.
  7823. * 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.
  7824. */
  7825. /**
  7826. * Sets the midtones Saturation value.
  7827. * 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.
  7828. */
  7829. midtonesSaturation: number;
  7830. /**
  7831. * Gets the midtones Exposure value.
  7832. * 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.
  7833. */
  7834. /**
  7835. * Sets the midtones Exposure value.
  7836. * 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.
  7837. */
  7838. midtonesExposure: number;
  7839. private _shadowsHue;
  7840. private _shadowsDensity;
  7841. private _shadowsSaturation;
  7842. private _shadowsExposure;
  7843. /**
  7844. * Gets the shadows Hue value.
  7845. * 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).
  7846. */
  7847. /**
  7848. * Sets the shadows Hue value.
  7849. * 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).
  7850. */
  7851. shadowsHue: number;
  7852. /**
  7853. * Gets the shadows Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. /**
  7858. * Sets the shadows Density value.
  7859. * 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.
  7860. * Values less than zero provide a filter of opposite hue.
  7861. */
  7862. shadowsDensity: number;
  7863. /**
  7864. * Gets the shadows Saturation value.
  7865. * 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.
  7866. */
  7867. /**
  7868. * Sets the shadows Saturation value.
  7869. * 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.
  7870. */
  7871. shadowsSaturation: number;
  7872. /**
  7873. * Gets the shadows Exposure value.
  7874. * 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.
  7875. */
  7876. /**
  7877. * Sets the shadows Exposure value.
  7878. * 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.
  7879. */
  7880. shadowsExposure: number;
  7881. /**
  7882. * Returns the class name
  7883. * @returns The class name
  7884. */
  7885. getClassName(): string;
  7886. /**
  7887. * Binds the color curves to the shader.
  7888. * @param colorCurves The color curve to bind
  7889. * @param effect The effect to bind to
  7890. * @param positiveUniform The positive uniform shader parameter
  7891. * @param neutralUniform The neutral uniform shader parameter
  7892. * @param negativeUniform The negative uniform shader parameter
  7893. */
  7894. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7895. /**
  7896. * Prepare the list of uniforms associated with the ColorCurves effects.
  7897. * @param uniformsList The list of uniforms used in the effect
  7898. */
  7899. static PrepareUniforms(uniformsList: string[]): void;
  7900. /**
  7901. * Returns color grading data based on a hue, density, saturation and exposure value.
  7902. * @param filterHue The hue of the color filter.
  7903. * @param filterDensity The density of the color filter.
  7904. * @param saturation The saturation.
  7905. * @param exposure The exposure.
  7906. * @param result The result data container.
  7907. */
  7908. private getColorGradingDataToRef;
  7909. /**
  7910. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7911. * @param value The input slider value in range [-100,100].
  7912. * @returns Adjusted value.
  7913. */
  7914. private static applyColorGradingSliderNonlinear;
  7915. /**
  7916. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7917. * @param hue The hue (H) input.
  7918. * @param saturation The saturation (S) input.
  7919. * @param brightness The brightness (B) input.
  7920. * @result An RGBA color represented as Vector4.
  7921. */
  7922. private static fromHSBToRef;
  7923. /**
  7924. * Returns a value clamped between min and max
  7925. * @param value The value to clamp
  7926. * @param min The minimum of value
  7927. * @param max The maximum of value
  7928. * @returns The clamped value.
  7929. */
  7930. private static clamp;
  7931. /**
  7932. * Clones the current color curve instance.
  7933. * @return The cloned curves
  7934. */
  7935. clone(): ColorCurves;
  7936. /**
  7937. * Serializes the current color curve instance to a json representation.
  7938. * @return a JSON representation
  7939. */
  7940. serialize(): any;
  7941. /**
  7942. * Parses the color curve from a json representation.
  7943. * @param source the JSON source to parse
  7944. * @return The parsed curves
  7945. */
  7946. static Parse(source: any): ColorCurves;
  7947. }
  7948. }
  7949. declare module BABYLON {
  7950. /**
  7951. * Interface to follow in your material defines to integrate easily the
  7952. * Image proccessing functions.
  7953. * @hidden
  7954. */
  7955. export interface IImageProcessingConfigurationDefines {
  7956. IMAGEPROCESSING: boolean;
  7957. VIGNETTE: boolean;
  7958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7959. VIGNETTEBLENDMODEOPAQUE: boolean;
  7960. TONEMAPPING: boolean;
  7961. TONEMAPPING_ACES: boolean;
  7962. CONTRAST: boolean;
  7963. EXPOSURE: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. }
  7971. /**
  7972. * @hidden
  7973. */
  7974. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7975. IMAGEPROCESSING: boolean;
  7976. VIGNETTE: boolean;
  7977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7978. VIGNETTEBLENDMODEOPAQUE: boolean;
  7979. TONEMAPPING: boolean;
  7980. TONEMAPPING_ACES: boolean;
  7981. CONTRAST: boolean;
  7982. COLORCURVES: boolean;
  7983. COLORGRADING: boolean;
  7984. COLORGRADING3D: boolean;
  7985. SAMPLER3DGREENDEPTH: boolean;
  7986. SAMPLER3DBGRMAP: boolean;
  7987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7988. EXPOSURE: boolean;
  7989. constructor();
  7990. }
  7991. /**
  7992. * This groups together the common properties used for image processing either in direct forward pass
  7993. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7994. * or not.
  7995. */
  7996. export class ImageProcessingConfiguration {
  7997. /**
  7998. * Default tone mapping applied in BabylonJS.
  7999. */
  8000. static readonly TONEMAPPING_STANDARD: number;
  8001. /**
  8002. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8003. * to other engines rendering to increase portability.
  8004. */
  8005. static readonly TONEMAPPING_ACES: number;
  8006. /**
  8007. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8008. */
  8009. colorCurves: Nullable<ColorCurves>;
  8010. private _colorCurvesEnabled;
  8011. /**
  8012. * Gets wether the color curves effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the color curves effect is enabled.
  8016. */
  8017. colorCurvesEnabled: boolean;
  8018. private _colorGradingTexture;
  8019. /**
  8020. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8021. */
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. colorGradingTexture: Nullable<BaseTexture>;
  8026. private _colorGradingEnabled;
  8027. /**
  8028. * Gets wether the color grading effect is enabled.
  8029. */
  8030. /**
  8031. * Sets wether the color grading effect is enabled.
  8032. */
  8033. colorGradingEnabled: boolean;
  8034. private _colorGradingWithGreenDepth;
  8035. /**
  8036. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. colorGradingWithGreenDepth: boolean;
  8042. private _colorGradingBGR;
  8043. /**
  8044. * Gets wether the color grading texture contains BGR values.
  8045. */
  8046. /**
  8047. * Sets wether the color grading texture contains BGR values.
  8048. */
  8049. colorGradingBGR: boolean;
  8050. /** @hidden */
  8051. _exposure: number;
  8052. /**
  8053. * Gets the Exposure used in the effect.
  8054. */
  8055. /**
  8056. * Sets the Exposure used in the effect.
  8057. */
  8058. exposure: number;
  8059. private _toneMappingEnabled;
  8060. /**
  8061. * Gets wether the tone mapping effect is enabled.
  8062. */
  8063. /**
  8064. * Sets wether the tone mapping effect is enabled.
  8065. */
  8066. toneMappingEnabled: boolean;
  8067. private _toneMappingType;
  8068. /**
  8069. * Gets the type of tone mapping effect.
  8070. */
  8071. /**
  8072. * Sets the type of tone mapping effect used in BabylonJS.
  8073. */
  8074. toneMappingType: number;
  8075. protected _contrast: number;
  8076. /**
  8077. * Gets the contrast used in the effect.
  8078. */
  8079. /**
  8080. * Sets the contrast used in the effect.
  8081. */
  8082. contrast: number;
  8083. /**
  8084. * Vignette stretch size.
  8085. */
  8086. vignetteStretch: number;
  8087. /**
  8088. * Vignette centre X Offset.
  8089. */
  8090. vignetteCentreX: number;
  8091. /**
  8092. * Vignette centre Y Offset.
  8093. */
  8094. vignetteCentreY: number;
  8095. /**
  8096. * Vignette weight or intensity of the vignette effect.
  8097. */
  8098. vignetteWeight: number;
  8099. /**
  8100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8101. * if vignetteEnabled is set to true.
  8102. */
  8103. vignetteColor: Color4;
  8104. /**
  8105. * Camera field of view used by the Vignette effect.
  8106. */
  8107. vignetteCameraFov: number;
  8108. private _vignetteBlendMode;
  8109. /**
  8110. * Gets the vignette blend mode allowing different kind of effect.
  8111. */
  8112. /**
  8113. * Sets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. vignetteBlendMode: number;
  8116. private _vignetteEnabled;
  8117. /**
  8118. * Gets wether the vignette effect is enabled.
  8119. */
  8120. /**
  8121. * Sets wether the vignette effect is enabled.
  8122. */
  8123. vignetteEnabled: boolean;
  8124. private _applyByPostProcess;
  8125. /**
  8126. * Gets wether the image processing is applied through a post process or not.
  8127. */
  8128. /**
  8129. * Sets wether the image processing is applied through a post process or not.
  8130. */
  8131. applyByPostProcess: boolean;
  8132. private _isEnabled;
  8133. /**
  8134. * Gets wether the image processing is enabled or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is enabled or not.
  8138. */
  8139. isEnabled: boolean;
  8140. /**
  8141. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8142. */
  8143. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8144. /**
  8145. * Method called each time the image processing information changes requires to recompile the effect.
  8146. */
  8147. protected _updateParameters(): void;
  8148. /**
  8149. * Gets the current class name.
  8150. * @return "ImageProcessingConfiguration"
  8151. */
  8152. getClassName(): string;
  8153. /**
  8154. * Prepare the list of uniforms associated with the Image Processing effects.
  8155. * @param uniforms The list of uniforms used in the effect
  8156. * @param defines the list of defines currently in use
  8157. */
  8158. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8159. /**
  8160. * Prepare the list of samplers associated with the Image Processing effects.
  8161. * @param samplersList The list of uniforms used in the effect
  8162. * @param defines the list of defines currently in use
  8163. */
  8164. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8165. /**
  8166. * Prepare the list of defines associated to the shader.
  8167. * @param defines the list of defines to complete
  8168. * @param forPostProcess Define if we are currently in post process mode or not
  8169. */
  8170. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8171. /**
  8172. * Returns true if all the image processing information are ready.
  8173. * @returns True if ready, otherwise, false
  8174. */
  8175. isReady(): boolean;
  8176. /**
  8177. * Binds the image processing to the shader.
  8178. * @param effect The effect to bind to
  8179. * @param aspectRatio Define the current aspect ratio of the effect
  8180. */
  8181. bind(effect: Effect, aspectRatio?: number): void;
  8182. /**
  8183. * Clones the current image processing instance.
  8184. * @return The cloned image processing
  8185. */
  8186. clone(): ImageProcessingConfiguration;
  8187. /**
  8188. * Serializes the current image processing instance to a json representation.
  8189. * @return a JSON representation
  8190. */
  8191. serialize(): any;
  8192. /**
  8193. * Parses the image processing from a json representation.
  8194. * @param source the JSON source to parse
  8195. * @return The parsed image processing
  8196. */
  8197. static Parse(source: any): ImageProcessingConfiguration;
  8198. private static _VIGNETTEMODE_MULTIPLY;
  8199. private static _VIGNETTEMODE_OPAQUE;
  8200. /**
  8201. * Used to apply the vignette as a mix with the pixel color.
  8202. */
  8203. static readonly VIGNETTEMODE_MULTIPLY: number;
  8204. /**
  8205. * Used to apply the vignette as a replacement of the pixel color.
  8206. */
  8207. static readonly VIGNETTEMODE_OPAQUE: number;
  8208. }
  8209. }
  8210. declare module BABYLON {
  8211. /** @hidden */
  8212. export var postprocessVertexShader: {
  8213. name: string;
  8214. shader: string;
  8215. };
  8216. }
  8217. declare module BABYLON {
  8218. /** Defines supported spaces */
  8219. export enum Space {
  8220. /** Local (object) space */
  8221. LOCAL = 0,
  8222. /** World space */
  8223. WORLD = 1,
  8224. /** Bone space */
  8225. BONE = 2
  8226. }
  8227. /** Defines the 3 main axes */
  8228. export class Axis {
  8229. /** X axis */
  8230. static X: Vector3;
  8231. /** Y axis */
  8232. static Y: Vector3;
  8233. /** Z axis */
  8234. static Z: Vector3;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8240. * This is the base of the follow, arc rotate cameras and Free camera
  8241. * @see http://doc.babylonjs.com/features/cameras
  8242. */
  8243. export class TargetCamera extends Camera {
  8244. private static _RigCamTransformMatrix;
  8245. private static _TargetTransformMatrix;
  8246. private static _TargetFocalPoint;
  8247. /**
  8248. * Define the current direction the camera is moving to
  8249. */
  8250. cameraDirection: Vector3;
  8251. /**
  8252. * Define the current rotation the camera is rotating to
  8253. */
  8254. cameraRotation: Vector2;
  8255. /**
  8256. * When set, the up vector of the camera will be updated by the rotation of the camera
  8257. */
  8258. updateUpVectorFromRotation: boolean;
  8259. private _tmpQuaternion;
  8260. /**
  8261. * Define the current rotation of the camera
  8262. */
  8263. rotation: Vector3;
  8264. /**
  8265. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8266. */
  8267. rotationQuaternion: Quaternion;
  8268. /**
  8269. * Define the current speed of the camera
  8270. */
  8271. speed: number;
  8272. /**
  8273. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8274. * around all axis.
  8275. */
  8276. noRotationConstraint: boolean;
  8277. /**
  8278. * Define the current target of the camera as an object or a position.
  8279. */
  8280. lockedTarget: any;
  8281. /** @hidden */
  8282. _currentTarget: Vector3;
  8283. /** @hidden */
  8284. _initialFocalDistance: number;
  8285. /** @hidden */
  8286. _viewMatrix: Matrix;
  8287. /** @hidden */
  8288. _camMatrix: Matrix;
  8289. /** @hidden */
  8290. _cameraTransformMatrix: Matrix;
  8291. /** @hidden */
  8292. _cameraRotationMatrix: Matrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /**
  8343. * Defines the target the camera should look at.
  8344. * @param target Defines the new target as a Vector or a mesh
  8345. */
  8346. setTarget(target: Vector3): void;
  8347. /**
  8348. * Return the current target position of the camera. This value is expressed in local space.
  8349. * @returns the target position
  8350. */
  8351. getTarget(): Vector3;
  8352. /** @hidden */
  8353. _decideIfNeedsToMove(): boolean;
  8354. /** @hidden */
  8355. _updatePosition(): void;
  8356. /** @hidden */
  8357. _checkInputs(): void;
  8358. protected _updateCameraRotationMatrix(): void;
  8359. /**
  8360. * 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)
  8361. * @returns the current camera
  8362. */
  8363. private _rotateUpVectorWithCameraRotationMatrix;
  8364. private _cachedRotationZ;
  8365. private _cachedQuaternionRotationZ;
  8366. /** @hidden */
  8367. _getViewMatrix(): Matrix;
  8368. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8369. /**
  8370. * @hidden
  8371. */
  8372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8373. /**
  8374. * @hidden
  8375. */
  8376. _updateRigCameras(): void;
  8377. private _getRigCamPositionAndTarget;
  8378. /**
  8379. * Gets the current object class name.
  8380. * @return the class name
  8381. */
  8382. getClassName(): string;
  8383. }
  8384. }
  8385. declare module BABYLON {
  8386. /**
  8387. * Gather the list of keyboard event types as constants.
  8388. */
  8389. export class KeyboardEventTypes {
  8390. /**
  8391. * The keydown event is fired when a key becomes active (pressed).
  8392. */
  8393. static readonly KEYDOWN: number;
  8394. /**
  8395. * The keyup event is fired when a key has been released.
  8396. */
  8397. static readonly KEYUP: number;
  8398. }
  8399. /**
  8400. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8401. */
  8402. export class KeyboardInfo {
  8403. /**
  8404. * Defines the type of event (KeyboardEventTypes)
  8405. */
  8406. type: number;
  8407. /**
  8408. * Defines the related dom event
  8409. */
  8410. event: KeyboardEvent;
  8411. /**
  8412. * Instantiates a new keyboard info.
  8413. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8414. * @param type Defines the type of event (KeyboardEventTypes)
  8415. * @param event Defines the related dom event
  8416. */
  8417. constructor(
  8418. /**
  8419. * Defines the type of event (KeyboardEventTypes)
  8420. */
  8421. type: number,
  8422. /**
  8423. * Defines the related dom event
  8424. */
  8425. event: KeyboardEvent);
  8426. }
  8427. /**
  8428. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8429. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8430. */
  8431. export class KeyboardInfoPre extends KeyboardInfo {
  8432. /**
  8433. * Defines the type of event (KeyboardEventTypes)
  8434. */
  8435. type: number;
  8436. /**
  8437. * Defines the related dom event
  8438. */
  8439. event: KeyboardEvent;
  8440. /**
  8441. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8442. */
  8443. skipOnPointerObservable: boolean;
  8444. /**
  8445. * Instantiates a new keyboard pre info.
  8446. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8447. * @param type Defines the type of event (KeyboardEventTypes)
  8448. * @param event Defines the related dom event
  8449. */
  8450. constructor(
  8451. /**
  8452. * Defines the type of event (KeyboardEventTypes)
  8453. */
  8454. type: number,
  8455. /**
  8456. * Defines the related dom event
  8457. */
  8458. event: KeyboardEvent);
  8459. }
  8460. }
  8461. declare module BABYLON {
  8462. /**
  8463. * Manage the keyboard inputs to control the movement of a free camera.
  8464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8465. */
  8466. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8467. /**
  8468. * Defines the camera the input is attached to.
  8469. */
  8470. camera: FreeCamera;
  8471. /**
  8472. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8473. */
  8474. keysUp: number[];
  8475. /**
  8476. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8477. */
  8478. keysDown: number[];
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8481. */
  8482. keysLeft: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8485. */
  8486. keysRight: number[];
  8487. private _keys;
  8488. private _onCanvasBlurObserver;
  8489. private _onKeyboardObserver;
  8490. private _engine;
  8491. private _scene;
  8492. /**
  8493. * Attach the input controls to a specific dom element to get the input from.
  8494. * @param element Defines the element the controls should be listened from
  8495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8496. */
  8497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8498. /**
  8499. * Detach the current controls from the specified dom element.
  8500. * @param element Defines the element to stop listening the inputs from
  8501. */
  8502. detachControl(element: Nullable<HTMLElement>): void;
  8503. /**
  8504. * Update the current camera state depending on the inputs that have been used this frame.
  8505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8506. */
  8507. checkInputs(): void;
  8508. /**
  8509. * Gets the class name of the current intput.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. /** @hidden */
  8514. _onLostFocus(): void;
  8515. /**
  8516. * Get the friendly name associated with the input class.
  8517. * @returns the input friendly name
  8518. */
  8519. getSimpleName(): string;
  8520. }
  8521. }
  8522. declare module BABYLON {
  8523. /**
  8524. * Interface describing all the common properties and methods a shadow light needs to implement.
  8525. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8526. * as well as binding the different shadow properties to the effects.
  8527. */
  8528. export interface IShadowLight extends Light {
  8529. /**
  8530. * The light id in the scene (used in scene.findLighById for instance)
  8531. */
  8532. id: string;
  8533. /**
  8534. * The position the shdow will be casted from.
  8535. */
  8536. position: Vector3;
  8537. /**
  8538. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8539. */
  8540. direction: Vector3;
  8541. /**
  8542. * The transformed position. Position of the light in world space taking parenting in account.
  8543. */
  8544. transformedPosition: Vector3;
  8545. /**
  8546. * The transformed direction. Direction of the light in world space taking parenting in account.
  8547. */
  8548. transformedDirection: Vector3;
  8549. /**
  8550. * The friendly name of the light in the scene.
  8551. */
  8552. name: string;
  8553. /**
  8554. * Defines the shadow projection clipping minimum z value.
  8555. */
  8556. shadowMinZ: number;
  8557. /**
  8558. * Defines the shadow projection clipping maximum z value.
  8559. */
  8560. shadowMaxZ: number;
  8561. /**
  8562. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8563. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8564. */
  8565. computeTransformedInformation(): boolean;
  8566. /**
  8567. * Gets the scene the light belongs to.
  8568. * @returns The scene
  8569. */
  8570. getScene(): Scene;
  8571. /**
  8572. * Callback defining a custom Projection Matrix Builder.
  8573. * This can be used to override the default projection matrix computation.
  8574. */
  8575. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8576. /**
  8577. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8578. * @param matrix The materix to updated with the projection information
  8579. * @param viewMatrix The transform matrix of the light
  8580. * @param renderList The list of mesh to render in the map
  8581. * @returns The current light
  8582. */
  8583. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8584. /**
  8585. * Gets the current depth scale used in ESM.
  8586. * @returns The scale
  8587. */
  8588. getDepthScale(): number;
  8589. /**
  8590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8591. * @returns true if a cube texture needs to be use
  8592. */
  8593. needCube(): boolean;
  8594. /**
  8595. * Detects if the projection matrix requires to be recomputed this frame.
  8596. * @returns true if it requires to be recomputed otherwise, false.
  8597. */
  8598. needProjectionMatrixCompute(): boolean;
  8599. /**
  8600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8601. */
  8602. forceProjectionMatrixCompute(): void;
  8603. /**
  8604. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8605. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8606. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8607. */
  8608. getShadowDirection(faceIndex?: number): Vector3;
  8609. /**
  8610. * Gets the minZ used for shadow according to both the scene and the light.
  8611. * @param activeCamera The camera we are returning the min for
  8612. * @returns the depth min z
  8613. */
  8614. getDepthMinZ(activeCamera: Camera): number;
  8615. /**
  8616. * Gets the maxZ used for shadow according to both the scene and the light.
  8617. * @param activeCamera The camera we are returning the max for
  8618. * @returns the depth max z
  8619. */
  8620. getDepthMaxZ(activeCamera: Camera): number;
  8621. }
  8622. /**
  8623. * Base implementation IShadowLight
  8624. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8625. */
  8626. export abstract class ShadowLight extends Light implements IShadowLight {
  8627. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8628. protected _position: Vector3;
  8629. protected _setPosition(value: Vector3): void;
  8630. /**
  8631. * Sets the position the shadow will be casted from. Also use as the light position for both
  8632. * point and spot lights.
  8633. */
  8634. /**
  8635. * Sets the position the shadow will be casted from. Also use as the light position for both
  8636. * point and spot lights.
  8637. */
  8638. position: Vector3;
  8639. protected _direction: Vector3;
  8640. protected _setDirection(value: Vector3): void;
  8641. /**
  8642. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8643. * Also use as the light direction on spot and directional lights.
  8644. */
  8645. /**
  8646. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8647. * Also use as the light direction on spot and directional lights.
  8648. */
  8649. direction: Vector3;
  8650. private _shadowMinZ;
  8651. /**
  8652. * Gets the shadow projection clipping minimum z value.
  8653. */
  8654. /**
  8655. * Sets the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. private _shadowMaxZ;
  8659. /**
  8660. * Sets the shadow projection clipping maximum z value.
  8661. */
  8662. /**
  8663. * Gets the shadow projection clipping maximum z value.
  8664. */
  8665. shadowMaxZ: number;
  8666. /**
  8667. * Callback defining a custom Projection Matrix Builder.
  8668. * This can be used to override the default projection matrix computation.
  8669. */
  8670. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8671. /**
  8672. * The transformed position. Position of the light in world space taking parenting in account.
  8673. */
  8674. transformedPosition: Vector3;
  8675. /**
  8676. * The transformed direction. Direction of the light in world space taking parenting in account.
  8677. */
  8678. transformedDirection: Vector3;
  8679. private _needProjectionMatrixCompute;
  8680. /**
  8681. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8682. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8683. */
  8684. computeTransformedInformation(): boolean;
  8685. /**
  8686. * Return the depth scale used for the shadow map.
  8687. * @returns the depth scale.
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8692. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8693. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8694. */
  8695. getShadowDirection(faceIndex?: number): Vector3;
  8696. /**
  8697. * Returns the ShadowLight absolute position in the World.
  8698. * @returns the position vector in world space
  8699. */
  8700. getAbsolutePosition(): Vector3;
  8701. /**
  8702. * Sets the ShadowLight direction toward the passed target.
  8703. * @param target The point to target in local space
  8704. * @returns the updated ShadowLight direction
  8705. */
  8706. setDirectionToTarget(target: Vector3): Vector3;
  8707. /**
  8708. * Returns the light rotation in euler definition.
  8709. * @returns the x y z rotation in local space.
  8710. */
  8711. getRotation(): Vector3;
  8712. /**
  8713. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8714. * @returns true if a cube texture needs to be use
  8715. */
  8716. needCube(): boolean;
  8717. /**
  8718. * Detects if the projection matrix requires to be recomputed this frame.
  8719. * @returns true if it requires to be recomputed otherwise, false.
  8720. */
  8721. needProjectionMatrixCompute(): boolean;
  8722. /**
  8723. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8724. */
  8725. forceProjectionMatrixCompute(): void;
  8726. /** @hidden */
  8727. _initCache(): void;
  8728. /** @hidden */
  8729. _isSynchronized(): boolean;
  8730. /**
  8731. * Computes the world matrix of the node
  8732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8733. * @returns the world matrix
  8734. */
  8735. computeWorldMatrix(force?: boolean): Matrix;
  8736. /**
  8737. * Gets the minZ used for shadow according to both the scene and the light.
  8738. * @param activeCamera The camera we are returning the min for
  8739. * @returns the depth min z
  8740. */
  8741. getDepthMinZ(activeCamera: Camera): number;
  8742. /**
  8743. * Gets the maxZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the max for
  8745. * @returns the depth max z
  8746. */
  8747. getDepthMaxZ(activeCamera: Camera): number;
  8748. /**
  8749. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8750. * @param matrix The materix to updated with the projection information
  8751. * @param viewMatrix The transform matrix of the light
  8752. * @param renderList The list of mesh to render in the map
  8753. * @returns The current light
  8754. */
  8755. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * "Static Class" containing the most commonly used helper while dealing with material for
  8761. * rendering purpose.
  8762. *
  8763. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8764. *
  8765. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8766. */
  8767. export class MaterialHelper {
  8768. /**
  8769. * Bind the current view position to an effect.
  8770. * @param effect The effect to be bound
  8771. * @param scene The scene the eyes position is used from
  8772. */
  8773. static BindEyePosition(effect: Effect, scene: Scene): void;
  8774. /**
  8775. * Helps preparing the defines values about the UVs in used in the effect.
  8776. * UVs are shared as much as we can accross channels in the shaders.
  8777. * @param texture The texture we are preparing the UVs for
  8778. * @param defines The defines to update
  8779. * @param key The channel key "diffuse", "specular"... used in the shader
  8780. */
  8781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8782. /**
  8783. * Binds a texture matrix value to its corrsponding uniform
  8784. * @param texture The texture to bind the matrix for
  8785. * @param uniformBuffer The uniform buffer receivin the data
  8786. * @param key The channel key "diffuse", "specular"... used in the shader
  8787. */
  8788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8789. /**
  8790. * Gets the current status of the fog (should it be enabled?)
  8791. * @param mesh defines the mesh to evaluate for fog support
  8792. * @param scene defines the hosting scene
  8793. * @returns true if fog must be enabled
  8794. */
  8795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8796. /**
  8797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8798. * @param mesh defines the current mesh
  8799. * @param scene defines the current scene
  8800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8801. * @param pointsCloud defines if point cloud rendering has to be turned on
  8802. * @param fogEnabled defines if fog has to be turned on
  8803. * @param alphaTest defines if alpha testing has to be turned on
  8804. * @param defines defines the current list of defines
  8805. */
  8806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8809. * @param scene defines the current scene
  8810. * @param engine defines the current engine
  8811. * @param defines specifies the list of active defines
  8812. * @param useInstances defines if instances have to be turned on
  8813. * @param useClipPlane defines if clip plane have to be turned on
  8814. */
  8815. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8816. /**
  8817. * Prepares the defines for bones
  8818. * @param mesh The mesh containing the geometry data we will draw
  8819. * @param defines The defines to update
  8820. */
  8821. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8822. /**
  8823. * Prepares the defines for morph targets
  8824. * @param mesh The mesh containing the geometry data we will draw
  8825. * @param defines The defines to update
  8826. */
  8827. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8828. /**
  8829. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8830. * @param mesh The mesh containing the geometry data we will draw
  8831. * @param defines The defines to update
  8832. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8833. * @param useBones Precise whether bones should be used or not (override mesh info)
  8834. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8835. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8836. * @returns false if defines are considered not dirty and have not been checked
  8837. */
  8838. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8839. /**
  8840. * Prepares the defines related to multiview
  8841. * @param scene The scene we are intending to draw
  8842. * @param defines The defines to update
  8843. */
  8844. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8845. /**
  8846. * Prepares the defines related to the light information passed in parameter
  8847. * @param scene The scene we are intending to draw
  8848. * @param mesh The mesh the effect is compiling for
  8849. * @param light The light the effect is compiling for
  8850. * @param lightIndex The index of the light
  8851. * @param defines The defines to update
  8852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8853. * @param state Defines the current state regarding what is needed (normals, etc...)
  8854. */
  8855. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8856. needNormals: boolean;
  8857. needRebuild: boolean;
  8858. shadowEnabled: boolean;
  8859. specularEnabled: boolean;
  8860. lightmapMode: boolean;
  8861. }): void;
  8862. /**
  8863. * Prepares the defines related to the light information passed in parameter
  8864. * @param scene The scene we are intending to draw
  8865. * @param mesh The mesh the effect is compiling for
  8866. * @param defines The defines to update
  8867. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8868. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8869. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8870. * @returns true if normals will be required for the rest of the effect
  8871. */
  8872. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8873. /**
  8874. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8875. * @param lightIndex defines the light index
  8876. * @param uniformsList The uniform list
  8877. * @param samplersList The sampler list
  8878. * @param projectedLightTexture defines if projected texture must be used
  8879. * @param uniformBuffersList defines an optional list of uniform buffers
  8880. */
  8881. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8882. /**
  8883. * Prepares the uniforms and samplers list to be used in the effect
  8884. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8885. * @param samplersList The sampler list
  8886. * @param defines The defines helping in the list generation
  8887. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8888. */
  8889. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8890. /**
  8891. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8892. * @param defines The defines to update while falling back
  8893. * @param fallbacks The authorized effect fallbacks
  8894. * @param maxSimultaneousLights The maximum number of lights allowed
  8895. * @param rank the current rank of the Effect
  8896. * @returns The newly affected rank
  8897. */
  8898. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8899. private static _TmpMorphInfluencers;
  8900. /**
  8901. * Prepares the list of attributes required for morph targets according to the effect defines.
  8902. * @param attribs The current list of supported attribs
  8903. * @param mesh The mesh to prepare the morph targets attributes for
  8904. * @param influencers The number of influencers
  8905. */
  8906. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8907. /**
  8908. * Prepares the list of attributes required for morph targets according to the effect defines.
  8909. * @param attribs The current list of supported attribs
  8910. * @param mesh The mesh to prepare the morph targets attributes for
  8911. * @param defines The current Defines of the effect
  8912. */
  8913. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the list of attributes required for bones according to the effect defines.
  8916. * @param attribs The current list of supported attribs
  8917. * @param mesh The mesh to prepare the bones attributes for
  8918. * @param defines The current Defines of the effect
  8919. * @param fallbacks The current efffect fallback strategy
  8920. */
  8921. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8922. /**
  8923. * Check and prepare the list of attributes required for instances according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param defines The current MaterialDefines of the effect
  8926. */
  8927. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8928. /**
  8929. * Add the list of attributes required for instances to the attribs array.
  8930. * @param attribs The current list of supported attribs
  8931. */
  8932. static PushAttributesForInstances(attribs: string[]): void;
  8933. /**
  8934. * Binds the light shadow information to the effect for the given mesh.
  8935. * @param light The light containing the generator
  8936. * @param scene The scene the lights belongs to
  8937. * @param mesh The mesh we are binding the information to render
  8938. * @param lightIndex The light index in the effect used to render the mesh
  8939. * @param effect The effect we are binding the data to
  8940. */
  8941. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8942. /**
  8943. * Binds the light information to the effect.
  8944. * @param light The light containing the generator
  8945. * @param effect The effect we are binding the data to
  8946. * @param lightIndex The light index in the effect used to render
  8947. */
  8948. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8949. /**
  8950. * Binds the lights information from the scene to the effect for the given mesh.
  8951. * @param light Light to bind
  8952. * @param lightIndex Light index
  8953. * @param scene The scene where the light belongs to
  8954. * @param mesh The mesh we are binding the information to render
  8955. * @param effect The effect we are binding the data to
  8956. * @param useSpecular Defines if specular is supported
  8957. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8958. */
  8959. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8960. /**
  8961. * Binds the lights information from the scene to the effect for the given mesh.
  8962. * @param scene The scene the lights belongs to
  8963. * @param mesh The mesh we are binding the information to render
  8964. * @param effect The effect we are binding the data to
  8965. * @param defines The generated defines for the effect
  8966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8967. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8968. */
  8969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8970. private static _tempFogColor;
  8971. /**
  8972. * Binds the fog information from the scene to the effect for the given mesh.
  8973. * @param scene The scene the lights belongs to
  8974. * @param mesh The mesh we are binding the information to render
  8975. * @param effect The effect we are binding the data to
  8976. * @param linearSpace Defines if the fog effect is applied in linear space
  8977. */
  8978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8979. /**
  8980. * Binds the bones information from the mesh to the effect.
  8981. * @param mesh The mesh we are binding the information to render
  8982. * @param effect The effect we are binding the data to
  8983. */
  8984. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8985. /**
  8986. * Binds the morph targets information from the mesh to the effect.
  8987. * @param abstractMesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. */
  8990. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8991. /**
  8992. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8993. * @param defines The generated defines used in the effect
  8994. * @param effect The effect we are binding the data to
  8995. * @param scene The scene we are willing to render with logarithmic scale for
  8996. */
  8997. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8998. /**
  8999. * Binds the clip plane information from the scene to the effect.
  9000. * @param scene The scene the clip plane information are extracted from
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindClipPlane(effect: Effect, scene: Scene): void;
  9004. }
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var packingFunctions: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapPixelShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var bonesDeclaration: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /** @hidden */
  9029. export var morphTargetsVertexGlobalDeclaration: {
  9030. name: string;
  9031. shader: string;
  9032. };
  9033. }
  9034. declare module BABYLON {
  9035. /** @hidden */
  9036. export var morphTargetsVertexDeclaration: {
  9037. name: string;
  9038. shader: string;
  9039. };
  9040. }
  9041. declare module BABYLON {
  9042. /** @hidden */
  9043. export var instancesDeclaration: {
  9044. name: string;
  9045. shader: string;
  9046. };
  9047. }
  9048. declare module BABYLON {
  9049. /** @hidden */
  9050. export var helperFunctions: {
  9051. name: string;
  9052. shader: string;
  9053. };
  9054. }
  9055. declare module BABYLON {
  9056. /** @hidden */
  9057. export var morphTargetsVertex: {
  9058. name: string;
  9059. shader: string;
  9060. };
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var instancesVertex: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var bonesVertex: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var shadowMapVertexShader: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var depthBoxBlurPixelShader: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9093. */
  9094. export interface ICustomShaderOptions {
  9095. /**
  9096. * Gets or sets the custom shader name to use
  9097. */
  9098. shaderName: string;
  9099. /**
  9100. * The list of attribute names used in the shader
  9101. */
  9102. attributes?: string[];
  9103. /**
  9104. * The list of unifrom names used in the shader
  9105. */
  9106. uniforms?: string[];
  9107. /**
  9108. * The list of sampler names used in the shader
  9109. */
  9110. samplers?: string[];
  9111. /**
  9112. * The list of defines used in the shader
  9113. */
  9114. defines?: string[];
  9115. }
  9116. /**
  9117. * Interface to implement to create a shadow generator compatible with BJS.
  9118. */
  9119. export interface IShadowGenerator {
  9120. /**
  9121. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9122. * @returns The render target texture if present otherwise, null
  9123. */
  9124. getShadowMap(): Nullable<RenderTargetTexture>;
  9125. /**
  9126. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9127. * @returns The render target texture if the shadow map is present otherwise, null
  9128. */
  9129. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9132. * @param subMesh The submesh we want to render in the shadow map
  9133. * @param useInstances Defines wether will draw in the map using instances
  9134. * @returns true if ready otherwise, false
  9135. */
  9136. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9137. /**
  9138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9139. * @param defines Defines of the material we want to update
  9140. * @param lightIndex Index of the light in the enabled light list of the material
  9141. */
  9142. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9143. /**
  9144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9145. * defined in the generator but impacting the effect).
  9146. * It implies the unifroms available on the materials are the standard BJS ones.
  9147. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9148. * @param effect The effect we are binfing the information for
  9149. */
  9150. bindShadowLight(lightIndex: string, effect: Effect): void;
  9151. /**
  9152. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9153. * (eq to shadow prjection matrix * light transform matrix)
  9154. * @returns The transform matrix used to create the shadow map
  9155. */
  9156. getTransformMatrix(): Matrix;
  9157. /**
  9158. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9159. * Cube and 2D textures for instance.
  9160. */
  9161. recreateShadowMap(): void;
  9162. /**
  9163. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9164. * @param onCompiled Callback triggered at the and of the effects compilation
  9165. * @param options Sets of optional options forcing the compilation with different modes
  9166. */
  9167. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9168. useInstances: boolean;
  9169. }>): void;
  9170. /**
  9171. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9172. * @param options Sets of optional options forcing the compilation with different modes
  9173. * @returns A promise that resolves when the compilation completes
  9174. */
  9175. forceCompilationAsync(options?: Partial<{
  9176. useInstances: boolean;
  9177. }>): Promise<void>;
  9178. /**
  9179. * Serializes the shadow generator setup to a json object.
  9180. * @returns The serialized JSON object
  9181. */
  9182. serialize(): any;
  9183. /**
  9184. * Disposes the Shadow map and related Textures and effects.
  9185. */
  9186. dispose(): void;
  9187. }
  9188. /**
  9189. * Default implementation IShadowGenerator.
  9190. * This is the main object responsible of generating shadows in the framework.
  9191. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9192. */
  9193. export class ShadowGenerator implements IShadowGenerator {
  9194. /**
  9195. * Shadow generator mode None: no filtering applied.
  9196. */
  9197. static readonly FILTER_NONE: number;
  9198. /**
  9199. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9200. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9201. */
  9202. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9203. /**
  9204. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9205. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9206. */
  9207. static readonly FILTER_POISSONSAMPLING: number;
  9208. /**
  9209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9215. * edge artifacts on steep falloff.
  9216. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9217. */
  9218. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9219. /**
  9220. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9221. * edge artifacts on steep falloff.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode PCF: Percentage Closer Filtering
  9227. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9228. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9229. */
  9230. static readonly FILTER_PCF: number;
  9231. /**
  9232. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9233. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9234. * Contact Hardening
  9235. */
  9236. static readonly FILTER_PCSS: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * Highest Quality.
  9240. *
  9241. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9242. *
  9243. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9244. */
  9245. static readonly QUALITY_HIGH: number;
  9246. /**
  9247. * Reserved for PCF and PCSS
  9248. * Good tradeoff for quality/perf cross devices
  9249. *
  9250. * Execute PCF on a 3*3 kernel.
  9251. *
  9252. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9253. */
  9254. static readonly QUALITY_MEDIUM: number;
  9255. /**
  9256. * Reserved for PCF and PCSS
  9257. * The lowest quality but the fastest.
  9258. *
  9259. * Execute PCF on a 1*1 kernel.
  9260. *
  9261. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9262. */
  9263. static readonly QUALITY_LOW: number;
  9264. /** Gets or sets the custom shader name to use */
  9265. customShaderOptions: ICustomShaderOptions;
  9266. /**
  9267. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9268. */
  9269. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9270. /**
  9271. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9272. */
  9273. onAfterShadowMapRenderObservable: Observable<Effect>;
  9274. /**
  9275. * Observable triggered before a mesh is rendered in the shadow map.
  9276. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9277. */
  9278. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9279. /**
  9280. * Observable triggered after a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9282. */
  9283. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. private _bias;
  9285. /**
  9286. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9287. */
  9288. /**
  9289. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. bias: number;
  9292. private _normalBias;
  9293. /**
  9294. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9295. */
  9296. /**
  9297. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. normalBias: number;
  9300. private _blurBoxOffset;
  9301. /**
  9302. * Gets the blur box offset: offset applied during the blur pass.
  9303. * Only useful if useKernelBlur = false
  9304. */
  9305. /**
  9306. * Sets the blur box offset: offset applied during the blur pass.
  9307. * Only useful if useKernelBlur = false
  9308. */
  9309. blurBoxOffset: number;
  9310. private _blurScale;
  9311. /**
  9312. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9313. * 2 means half of the size.
  9314. */
  9315. /**
  9316. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9317. * 2 means half of the size.
  9318. */
  9319. blurScale: number;
  9320. private _blurKernel;
  9321. /**
  9322. * Gets the blur kernel: kernel size of the blur pass.
  9323. * Only useful if useKernelBlur = true
  9324. */
  9325. /**
  9326. * Sets the blur kernel: kernel size of the blur pass.
  9327. * Only useful if useKernelBlur = true
  9328. */
  9329. blurKernel: number;
  9330. private _useKernelBlur;
  9331. /**
  9332. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9333. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9334. */
  9335. /**
  9336. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9337. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9338. */
  9339. useKernelBlur: boolean;
  9340. private _depthScale;
  9341. /**
  9342. * Gets the depth scale used in ESM mode.
  9343. */
  9344. /**
  9345. * Sets the depth scale used in ESM mode.
  9346. * This can override the scale stored on the light.
  9347. */
  9348. depthScale: number;
  9349. private _filter;
  9350. /**
  9351. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9352. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9353. */
  9354. /**
  9355. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9356. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9357. */
  9358. filter: number;
  9359. /**
  9360. * Gets if the current filter is set to Poisson Sampling.
  9361. */
  9362. /**
  9363. * Sets the current filter to Poisson Sampling.
  9364. */
  9365. usePoissonSampling: boolean;
  9366. /**
  9367. * Gets if the current filter is set to ESM.
  9368. */
  9369. /**
  9370. * Sets the current filter is to ESM.
  9371. */
  9372. useExponentialShadowMap: boolean;
  9373. /**
  9374. * Gets if the current filter is set to filtered ESM.
  9375. */
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. useBlurExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. /**
  9385. * Sets the current filter to "close ESM" (using the inverse of the
  9386. * exponential to prevent steep falloff artifacts).
  9387. */
  9388. useCloseExponentialShadowMap: boolean;
  9389. /**
  9390. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. /**
  9394. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9395. * exponential to prevent steep falloff artifacts).
  9396. */
  9397. useBlurCloseExponentialShadowMap: boolean;
  9398. /**
  9399. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9400. */
  9401. /**
  9402. * Sets the current filter to "PCF" (percentage closer filtering).
  9403. */
  9404. usePercentageCloserFiltering: boolean;
  9405. private _filteringQuality;
  9406. /**
  9407. * Gets the PCF or PCSS Quality.
  9408. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9409. */
  9410. /**
  9411. * Sets the PCF or PCSS Quality.
  9412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9413. */
  9414. filteringQuality: number;
  9415. /**
  9416. * Gets if the current filter is set to "PCSS" (contact hardening).
  9417. */
  9418. /**
  9419. * Sets the current filter to "PCSS" (contact hardening).
  9420. */
  9421. useContactHardeningShadow: boolean;
  9422. private _contactHardeningLightSizeUVRatio;
  9423. /**
  9424. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9425. * Using a ratio helps keeping shape stability independently of the map size.
  9426. *
  9427. * It does not account for the light projection as it was having too much
  9428. * instability during the light setup or during light position changes.
  9429. *
  9430. * Only valid if useContactHardeningShadow is true.
  9431. */
  9432. /**
  9433. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9434. * Using a ratio helps keeping shape stability independently of the map size.
  9435. *
  9436. * It does not account for the light projection as it was having too much
  9437. * instability during the light setup or during light position changes.
  9438. *
  9439. * Only valid if useContactHardeningShadow is true.
  9440. */
  9441. contactHardeningLightSizeUVRatio: number;
  9442. private _darkness;
  9443. /** Gets or sets the actual darkness of a shadow */
  9444. darkness: number;
  9445. /**
  9446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9447. * 0 means strongest and 1 would means no shadow.
  9448. * @returns the darkness.
  9449. */
  9450. getDarkness(): number;
  9451. /**
  9452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9454. * @returns the shadow generator allowing fluent coding.
  9455. */
  9456. setDarkness(darkness: number): ShadowGenerator;
  9457. private _transparencyShadow;
  9458. /** Gets or sets the ability to have transparent shadow */
  9459. transparencyShadow: boolean;
  9460. /**
  9461. * Sets the ability to have transparent shadow (boolean).
  9462. * @param transparent True if transparent else False
  9463. * @returns the shadow generator allowing fluent coding
  9464. */
  9465. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9466. private _shadowMap;
  9467. private _shadowMap2;
  9468. /**
  9469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9470. * @returns The render target texture if present otherwise, null
  9471. */
  9472. getShadowMap(): Nullable<RenderTargetTexture>;
  9473. /**
  9474. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9475. * @returns The render target texture if the shadow map is present otherwise, null
  9476. */
  9477. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the class name of that object
  9480. * @returns "ShadowGenerator"
  9481. */
  9482. getClassName(): string;
  9483. /**
  9484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9485. * @param mesh Mesh to add
  9486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9487. * @returns the Shadow Generator itself
  9488. */
  9489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9490. /**
  9491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9492. * @param mesh Mesh to remove
  9493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9494. * @returns the Shadow Generator itself
  9495. */
  9496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9497. /**
  9498. * Controls the extent to which the shadows fade out at the edge of the frustum
  9499. * Used only by directionals and spots
  9500. */
  9501. frustumEdgeFalloff: number;
  9502. private _light;
  9503. /**
  9504. * Returns the associated light object.
  9505. * @returns the light generating the shadow
  9506. */
  9507. getLight(): IShadowLight;
  9508. /**
  9509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9511. * It might on the other hand introduce peter panning.
  9512. */
  9513. forceBackFacesOnly: boolean;
  9514. private _scene;
  9515. private _lightDirection;
  9516. private _effect;
  9517. private _viewMatrix;
  9518. private _projectionMatrix;
  9519. private _transformMatrix;
  9520. private _cachedPosition;
  9521. private _cachedDirection;
  9522. private _cachedDefines;
  9523. private _currentRenderID;
  9524. private _boxBlurPostprocess;
  9525. private _kernelBlurXPostprocess;
  9526. private _kernelBlurYPostprocess;
  9527. private _blurPostProcesses;
  9528. private _mapSize;
  9529. private _currentFaceIndex;
  9530. private _currentFaceIndexCache;
  9531. private _textureType;
  9532. private _defaultTextureMatrix;
  9533. /** @hidden */
  9534. static _SceneComponentInitialization: (scene: Scene) => void;
  9535. /**
  9536. * Creates a ShadowGenerator object.
  9537. * A ShadowGenerator is the required tool to use the shadows.
  9538. * Each light casting shadows needs to use its own ShadowGenerator.
  9539. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9540. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9541. * @param light The light object generating the shadows.
  9542. * @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.
  9543. */
  9544. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9545. private _initializeGenerator;
  9546. private _initializeShadowMap;
  9547. private _initializeBlurRTTAndPostProcesses;
  9548. private _renderForShadowMap;
  9549. private _renderSubMeshForShadowMap;
  9550. private _applyFilterValues;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9569. * @param subMesh The submesh we want to render in the shadow map
  9570. * @param useInstances Defines wether will draw in the map using instances
  9571. * @returns true if ready otherwise, false
  9572. */
  9573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9574. /**
  9575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9576. * @param defines Defines of the material we want to update
  9577. * @param lightIndex Index of the light in the enabled light list of the material
  9578. */
  9579. prepareDefines(defines: any, lightIndex: number): void;
  9580. /**
  9581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9582. * defined in the generator but impacting the effect).
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. private _disposeBlurPostProcesses;
  9599. private _disposeRTTandPostProcesses;
  9600. /**
  9601. * Disposes the ShadowGenerator.
  9602. * Returns nothing.
  9603. */
  9604. dispose(): void;
  9605. /**
  9606. * Serializes the shadow generator setup to a json object.
  9607. * @returns The serialized JSON object
  9608. */
  9609. serialize(): any;
  9610. /**
  9611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9612. * @param parsedShadowGenerator The JSON object to parse
  9613. * @param scene The scene to create the shadow map for
  9614. * @returns The parsed shadow generator
  9615. */
  9616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9617. }
  9618. }
  9619. declare module BABYLON {
  9620. /**
  9621. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9622. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9623. * 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.
  9624. */
  9625. export abstract class Light extends Node {
  9626. /**
  9627. * Falloff Default: light is falling off following the material specification:
  9628. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9629. */
  9630. static readonly FALLOFF_DEFAULT: number;
  9631. /**
  9632. * Falloff Physical: light is falling off following the inverse squared distance law.
  9633. */
  9634. static readonly FALLOFF_PHYSICAL: number;
  9635. /**
  9636. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9637. * to enhance interoperability with other engines.
  9638. */
  9639. static readonly FALLOFF_GLTF: number;
  9640. /**
  9641. * Falloff Standard: light is falling off like in the standard material
  9642. * to enhance interoperability with other materials.
  9643. */
  9644. static readonly FALLOFF_STANDARD: number;
  9645. /**
  9646. * If every light affecting the material is in this lightmapMode,
  9647. * material.lightmapTexture adds or multiplies
  9648. * (depends on material.useLightmapAsShadowmap)
  9649. * after every other light calculations.
  9650. */
  9651. static readonly LIGHTMAP_DEFAULT: number;
  9652. /**
  9653. * material.lightmapTexture as only diffuse lighting from this light
  9654. * adds only specular lighting from this light
  9655. * adds dynamic shadows
  9656. */
  9657. static readonly LIGHTMAP_SPECULAR: number;
  9658. /**
  9659. * material.lightmapTexture as only lighting
  9660. * no light calculation from this light
  9661. * only adds dynamic shadows from this light
  9662. */
  9663. static readonly LIGHTMAP_SHADOWSONLY: number;
  9664. /**
  9665. * Each light type uses the default quantity according to its type:
  9666. * point/spot lights use luminous intensity
  9667. * directional lights use illuminance
  9668. */
  9669. static readonly INTENSITYMODE_AUTOMATIC: number;
  9670. /**
  9671. * lumen (lm)
  9672. */
  9673. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9674. /**
  9675. * candela (lm/sr)
  9676. */
  9677. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9678. /**
  9679. * lux (lm/m^2)
  9680. */
  9681. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9682. /**
  9683. * nit (cd/m^2)
  9684. */
  9685. static readonly INTENSITYMODE_LUMINANCE: number;
  9686. /**
  9687. * Light type const id of the point light.
  9688. */
  9689. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9690. /**
  9691. * Light type const id of the directional light.
  9692. */
  9693. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9694. /**
  9695. * Light type const id of the spot light.
  9696. */
  9697. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9698. /**
  9699. * Light type const id of the hemispheric light.
  9700. */
  9701. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9702. /**
  9703. * Diffuse gives the basic color to an object.
  9704. */
  9705. diffuse: Color3;
  9706. /**
  9707. * Specular produces a highlight color on an object.
  9708. * Note: This is note affecting PBR materials.
  9709. */
  9710. specular: Color3;
  9711. /**
  9712. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9713. * falling off base on range or angle.
  9714. * This can be set to any values in Light.FALLOFF_x.
  9715. *
  9716. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9717. * other types of materials.
  9718. */
  9719. falloffType: number;
  9720. /**
  9721. * Strength of the light.
  9722. * Note: By default it is define in the framework own unit.
  9723. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9724. */
  9725. intensity: number;
  9726. private _range;
  9727. protected _inverseSquaredRange: number;
  9728. /**
  9729. * Defines how far from the source the light is impacting in scene units.
  9730. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9731. */
  9732. /**
  9733. * Defines how far from the source the light is impacting in scene units.
  9734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9735. */
  9736. range: number;
  9737. /**
  9738. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9739. * of light.
  9740. */
  9741. private _photometricScale;
  9742. private _intensityMode;
  9743. /**
  9744. * Gets the photometric scale used to interpret the intensity.
  9745. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9746. */
  9747. /**
  9748. * Sets the photometric scale used to interpret the intensity.
  9749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9750. */
  9751. intensityMode: number;
  9752. private _radius;
  9753. /**
  9754. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9755. */
  9756. /**
  9757. * sets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. radius: number;
  9760. private _renderPriority;
  9761. /**
  9762. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9763. * exceeding the number allowed of the materials.
  9764. */
  9765. renderPriority: number;
  9766. private _shadowEnabled;
  9767. /**
  9768. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9769. * the current shadow generator.
  9770. */
  9771. /**
  9772. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9773. * the current shadow generator.
  9774. */
  9775. shadowEnabled: boolean;
  9776. private _includedOnlyMeshes;
  9777. /**
  9778. * Gets the only meshes impacted by this light.
  9779. */
  9780. /**
  9781. * Sets the only meshes impacted by this light.
  9782. */
  9783. includedOnlyMeshes: AbstractMesh[];
  9784. private _excludedMeshes;
  9785. /**
  9786. * Gets the meshes not impacted by this light.
  9787. */
  9788. /**
  9789. * Sets the meshes not impacted by this light.
  9790. */
  9791. excludedMeshes: AbstractMesh[];
  9792. private _excludeWithLayerMask;
  9793. /**
  9794. * Gets the layer id use to find what meshes are not impacted by the light.
  9795. * Inactive if 0
  9796. */
  9797. /**
  9798. * Sets the layer id use to find what meshes are not impacted by the light.
  9799. * Inactive if 0
  9800. */
  9801. excludeWithLayerMask: number;
  9802. private _includeOnlyWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. includeOnlyWithLayerMask: number;
  9812. private _lightmapMode;
  9813. /**
  9814. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9815. */
  9816. /**
  9817. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. lightmapMode: number;
  9820. /**
  9821. * Shadow generator associted to the light.
  9822. * @hidden Internal use only.
  9823. */
  9824. _shadowGenerator: Nullable<IShadowGenerator>;
  9825. /**
  9826. * @hidden Internal use only.
  9827. */
  9828. _excludedMeshesIds: string[];
  9829. /**
  9830. * @hidden Internal use only.
  9831. */
  9832. _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */
  9837. _uniformBuffer: UniformBuffer;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Returns the string "Light".
  9855. * @returns the class name
  9856. */
  9857. getClassName(): string;
  9858. /** @hidden */
  9859. readonly _isLight: boolean;
  9860. /**
  9861. * Converts the light information to a readable string for debug purpose.
  9862. * @param fullDetails Supports for multiple levels of logging within scene loading
  9863. * @returns the human readable light info
  9864. */
  9865. toString(fullDetails?: boolean): string;
  9866. /** @hidden */
  9867. protected _syncParentEnabledState(): void;
  9868. /**
  9869. * Set the enabled state of this node.
  9870. * @param value - the new enabled state
  9871. */
  9872. setEnabled(value: boolean): void;
  9873. /**
  9874. * Returns the Light associated shadow generator if any.
  9875. * @return the associated shadow generator.
  9876. */
  9877. getShadowGenerator(): Nullable<IShadowGenerator>;
  9878. /**
  9879. * Returns a Vector3, the absolute light position in the World.
  9880. * @returns the world space position of the light
  9881. */
  9882. getAbsolutePosition(): Vector3;
  9883. /**
  9884. * Specifies if the light will affect the passed mesh.
  9885. * @param mesh The mesh to test against the light
  9886. * @return true the mesh is affected otherwise, false.
  9887. */
  9888. canAffectMesh(mesh: AbstractMesh): boolean;
  9889. /**
  9890. * Sort function to order lights for rendering.
  9891. * @param a First Light object to compare to second.
  9892. * @param b Second Light object to compare first.
  9893. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9894. */
  9895. static CompareLightsPriority(a: Light, b: Light): number;
  9896. /**
  9897. * Releases resources associated with this node.
  9898. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9899. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9900. */
  9901. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9902. /**
  9903. * Returns the light type ID (integer).
  9904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9905. */
  9906. getTypeID(): number;
  9907. /**
  9908. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9909. * @returns the scaled intensity in intensity mode unit
  9910. */
  9911. getScaledIntensity(): number;
  9912. /**
  9913. * Returns a new Light object, named "name", from the current one.
  9914. * @param name The name of the cloned light
  9915. * @returns the new created light
  9916. */
  9917. clone(name: string): Nullable<Light>;
  9918. /**
  9919. * Serializes the current light into a Serialization object.
  9920. * @returns the serialized object.
  9921. */
  9922. serialize(): any;
  9923. /**
  9924. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9925. * This new light is named "name" and added to the passed scene.
  9926. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9927. * @param name The friendly name of the light
  9928. * @param scene The scene the new light will belong to
  9929. * @returns the constructor function
  9930. */
  9931. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9932. /**
  9933. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9934. * @param parsedLight The JSON representation of the light
  9935. * @param scene The scene to create the parsed light in
  9936. * @returns the created light after parsing
  9937. */
  9938. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9939. private _hookArrayForExcluded;
  9940. private _hookArrayForIncludedOnly;
  9941. private _resyncMeshes;
  9942. /**
  9943. * Forces the meshes to update their light related information in their rendering used effects
  9944. * @hidden Internal Use Only
  9945. */
  9946. _markMeshesAsLightDirty(): void;
  9947. /**
  9948. * Recomputes the cached photometric scale if needed.
  9949. */
  9950. private _computePhotometricScale;
  9951. /**
  9952. * Returns the Photometric Scale according to the light type and intensity mode.
  9953. */
  9954. private _getPhotometricScale;
  9955. /**
  9956. * Reorder the light in the scene according to their defined priority.
  9957. * @hidden Internal Use Only
  9958. */
  9959. _reorderLightsInScene(): void;
  9960. /**
  9961. * Prepares the list of defines specific to the light type.
  9962. * @param defines the list of defines
  9963. * @param lightIndex defines the index of the light for the effect
  9964. */
  9965. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Interface used to define Action
  9971. */
  9972. export interface IAction {
  9973. /**
  9974. * Trigger for the action
  9975. */
  9976. trigger: number;
  9977. /** Options of the trigger */
  9978. triggerOptions: any;
  9979. /**
  9980. * Gets the trigger parameters
  9981. * @returns the trigger parameters
  9982. */
  9983. getTriggerParameter(): any;
  9984. /**
  9985. * Internal only - executes current action event
  9986. * @hidden
  9987. */
  9988. _executeCurrent(evt?: ActionEvent): void;
  9989. /**
  9990. * Serialize placeholder for child classes
  9991. * @param parent of child
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. /**
  9996. * Internal only
  9997. * @hidden
  9998. */
  9999. _prepare(): void;
  10000. /**
  10001. * Internal only - manager for action
  10002. * @hidden
  10003. */
  10004. _actionManager: AbstractActionManager;
  10005. /**
  10006. * Adds action to chain of actions, may be a DoNothingAction
  10007. * @param action defines the next action to execute
  10008. * @returns The action passed in
  10009. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10010. */
  10011. then(action: IAction): IAction;
  10012. }
  10013. /**
  10014. * The action to be carried out following a trigger
  10015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10016. */
  10017. export class Action implements IAction {
  10018. /** the trigger, with or without parameters, for the action */
  10019. triggerOptions: any;
  10020. /**
  10021. * Trigger for the action
  10022. */
  10023. trigger: number;
  10024. /**
  10025. * Internal only - manager for action
  10026. * @hidden
  10027. */
  10028. _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */
  10049. _prepare(): void;
  10050. /**
  10051. * Gets the trigger parameters
  10052. * @returns the trigger parameters
  10053. */
  10054. getTriggerParameter(): any;
  10055. /**
  10056. * Internal only - executes current action event
  10057. * @hidden
  10058. */
  10059. _executeCurrent(evt?: ActionEvent): void;
  10060. /**
  10061. * Execute placeholder for child classes
  10062. * @param evt optional action event
  10063. */
  10064. execute(evt?: ActionEvent): void;
  10065. /**
  10066. * Skips to next active action
  10067. */
  10068. skipToNextActiveAction(): void;
  10069. /**
  10070. * Adds action to chain of actions, may be a DoNothingAction
  10071. * @param action defines the next action to execute
  10072. * @returns The action passed in
  10073. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10074. */
  10075. then(action: Action): Action;
  10076. /**
  10077. * Internal only
  10078. * @hidden
  10079. */
  10080. _getProperty(propertyPath: string): string;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getEffectiveTarget(target: any, propertyPath: string): any;
  10086. /**
  10087. * Serialize placeholder for child classes
  10088. * @param parent of child
  10089. * @returns the serialized object
  10090. */
  10091. serialize(parent: any): any;
  10092. /**
  10093. * Internal only called by serialize
  10094. * @hidden
  10095. */
  10096. protected _serialize(serializedAction: any, parent?: any): any;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */
  10101. static _SerializeValueAsString: (value: any) => string;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _GetTargetProperty: (target: Node | Scene) => {
  10107. name: string;
  10108. targetType: string;
  10109. value: string;
  10110. };
  10111. }
  10112. }
  10113. declare module BABYLON {
  10114. /**
  10115. * A Condition applied to an Action
  10116. */
  10117. export class Condition {
  10118. /**
  10119. * Internal only - manager for action
  10120. * @hidden
  10121. */
  10122. _actionManager: ActionManager;
  10123. /**
  10124. * Internal only
  10125. * @hidden
  10126. */
  10127. _evaluationId: number;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _currentResult: boolean;
  10133. /**
  10134. * Creates a new Condition
  10135. * @param actionManager the manager of the action the condition is applied to
  10136. */
  10137. constructor(actionManager: ActionManager);
  10138. /**
  10139. * Check if the current condition is valid
  10140. * @returns a boolean
  10141. */
  10142. isValid(): boolean;
  10143. /**
  10144. * Internal only
  10145. * @hidden
  10146. */
  10147. _getProperty(propertyPath: string): string;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getEffectiveTarget(target: any, propertyPath: string): any;
  10153. /**
  10154. * Serialize placeholder for child classes
  10155. * @returns the serialized object
  10156. */
  10157. serialize(): any;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. protected _serialize(serializedCondition: any): any;
  10163. }
  10164. /**
  10165. * Defines specific conditional operators as extensions of Condition
  10166. */
  10167. export class ValueCondition extends Condition {
  10168. /** path to specify the property of the target the conditional operator uses */
  10169. propertyPath: string;
  10170. /** the value compared by the conditional operator against the current value of the property */
  10171. value: any;
  10172. /** the conditional operator, default ValueCondition.IsEqual */
  10173. operator: number;
  10174. /**
  10175. * Internal only
  10176. * @hidden
  10177. */
  10178. private static _IsEqual;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsDifferent;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsGreater;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsLesser;
  10194. /**
  10195. * returns the number for IsEqual
  10196. */
  10197. static readonly IsEqual: number;
  10198. /**
  10199. * Returns the number for IsDifferent
  10200. */
  10201. static readonly IsDifferent: number;
  10202. /**
  10203. * Returns the number for IsGreater
  10204. */
  10205. static readonly IsGreater: number;
  10206. /**
  10207. * Returns the number for IsLesser
  10208. */
  10209. static readonly IsLesser: number;
  10210. /**
  10211. * Internal only The action manager for the condition
  10212. * @hidden
  10213. */
  10214. _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _effectiveTarget;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _property;
  10230. /**
  10231. * Creates a new ValueCondition
  10232. * @param actionManager manager for the action the condition applies to
  10233. * @param target for the action
  10234. * @param propertyPath path to specify the property of the target the conditional operator uses
  10235. * @param value the value compared by the conditional operator against the current value of the property
  10236. * @param operator the conditional operator, default ValueCondition.IsEqual
  10237. */
  10238. constructor(actionManager: ActionManager, target: any,
  10239. /** path to specify the property of the target the conditional operator uses */
  10240. propertyPath: string,
  10241. /** the value compared by the conditional operator against the current value of the property */
  10242. value: any,
  10243. /** the conditional operator, default ValueCondition.IsEqual */
  10244. operator?: number);
  10245. /**
  10246. * Compares the given value with the property value for the specified conditional operator
  10247. * @returns the result of the comparison
  10248. */
  10249. isValid(): boolean;
  10250. /**
  10251. * Serialize the ValueCondition into a JSON compatible object
  10252. * @returns serialization object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Gets the name of the conditional operator for the ValueCondition
  10257. * @param operator the conditional operator
  10258. * @returns the name
  10259. */
  10260. static GetOperatorName(operator: number): string;
  10261. }
  10262. /**
  10263. * Defines a predicate condition as an extension of Condition
  10264. */
  10265. export class PredicateCondition extends Condition {
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. /**
  10274. * Creates a new PredicateCondition
  10275. * @param actionManager manager for the action the condition applies to
  10276. * @param predicate defines the predicate function used to validate the condition
  10277. */
  10278. constructor(actionManager: ActionManager,
  10279. /** defines the predicate function used to validate the condition */
  10280. predicate: () => boolean);
  10281. /**
  10282. * @returns the validity of the predicate condition
  10283. */
  10284. isValid(): boolean;
  10285. }
  10286. /**
  10287. * Defines a state condition as an extension of Condition
  10288. */
  10289. export class StateCondition extends Condition {
  10290. /** Value to compare with target state */
  10291. value: string;
  10292. /**
  10293. * Internal only - manager for action
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Creates a new StateCondition
  10304. * @param actionManager manager for the action the condition applies to
  10305. * @param target of the condition
  10306. * @param value to compare with target state
  10307. */
  10308. constructor(actionManager: ActionManager, target: any,
  10309. /** Value to compare with target state */
  10310. value: string);
  10311. /**
  10312. * Gets a boolean indicating if the current condition is met
  10313. * @returns the validity of the state
  10314. */
  10315. isValid(): boolean;
  10316. /**
  10317. * Serialize the StateCondition into a JSON compatible object
  10318. * @returns serialization object
  10319. */
  10320. serialize(): any;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This defines an action responsible to toggle a boolean once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SwitchBooleanAction extends Action {
  10329. /**
  10330. * The path to the boolean property in the target object
  10331. */
  10332. propertyPath: string;
  10333. private _target;
  10334. private _effectiveTarget;
  10335. private _property;
  10336. /**
  10337. * Instantiate the action
  10338. * @param triggerOptions defines the trigger options
  10339. * @param target defines the object containing the boolean
  10340. * @param propertyPath defines the path to the boolean property in the target object
  10341. * @param condition defines the trigger related conditions
  10342. */
  10343. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10344. /** @hidden */
  10345. _prepare(): void;
  10346. /**
  10347. * Execute the action toggle the boolean value.
  10348. */
  10349. execute(): void;
  10350. /**
  10351. * Serializes the actions and its related information.
  10352. * @param parent defines the object to serialize in
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. }
  10357. /**
  10358. * This defines an action responsible to set a the state field of the target
  10359. * to a desired value once triggered.
  10360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10361. */
  10362. export class SetStateAction extends Action {
  10363. /**
  10364. * The value to store in the state field.
  10365. */
  10366. value: string;
  10367. private _target;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the state property
  10372. * @param value defines the value to store in the state field
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10376. /**
  10377. * Execute the action and store the value on the target state property.
  10378. */
  10379. execute(): void;
  10380. /**
  10381. * Serializes the actions and its related information.
  10382. * @param parent defines the object to serialize in
  10383. * @returns the serialized object
  10384. */
  10385. serialize(parent: any): any;
  10386. }
  10387. /**
  10388. * This defines an action responsible to set a property of the target
  10389. * to a desired value once triggered.
  10390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10391. */
  10392. export class SetValueAction extends Action {
  10393. /**
  10394. * The path of the property to set in the target.
  10395. */
  10396. propertyPath: string;
  10397. /**
  10398. * The value to set in the property
  10399. */
  10400. value: any;
  10401. private _target;
  10402. private _effectiveTarget;
  10403. private _property;
  10404. /**
  10405. * Instantiate the action
  10406. * @param triggerOptions defines the trigger options
  10407. * @param target defines the object containing the property
  10408. * @param propertyPath defines the path of the property to set in the target
  10409. * @param value defines the value to set in the property
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10413. /** @hidden */
  10414. _prepare(): void;
  10415. /**
  10416. * Execute the action and set the targetted property to the desired value.
  10417. */
  10418. execute(): void;
  10419. /**
  10420. * Serializes the actions and its related information.
  10421. * @param parent defines the object to serialize in
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. }
  10426. /**
  10427. * This defines an action responsible to increment the target value
  10428. * to a desired value once triggered.
  10429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10430. */
  10431. export class IncrementValueAction extends Action {
  10432. /**
  10433. * The path of the property to increment in the target.
  10434. */
  10435. propertyPath: string;
  10436. /**
  10437. * The value we should increment the property by.
  10438. */
  10439. value: any;
  10440. private _target;
  10441. private _effectiveTarget;
  10442. private _property;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the property
  10447. * @param propertyPath defines the path of the property to increment in the target
  10448. * @param value defines the value value we should increment the property by
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10452. /** @hidden */
  10453. _prepare(): void;
  10454. /**
  10455. * Execute the action and increment the target of the value amount.
  10456. */
  10457. execute(): void;
  10458. /**
  10459. * Serializes the actions and its related information.
  10460. * @param parent defines the object to serialize in
  10461. * @returns the serialized object
  10462. */
  10463. serialize(parent: any): any;
  10464. }
  10465. /**
  10466. * This defines an action responsible to start an animation once triggered.
  10467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10468. */
  10469. export class PlayAnimationAction extends Action {
  10470. /**
  10471. * Where the animation should start (animation frame)
  10472. */
  10473. from: number;
  10474. /**
  10475. * Where the animation should stop (animation frame)
  10476. */
  10477. to: number;
  10478. /**
  10479. * Define if the animation should loop or stop after the first play.
  10480. */
  10481. loop?: boolean;
  10482. private _target;
  10483. /**
  10484. * Instantiate the action
  10485. * @param triggerOptions defines the trigger options
  10486. * @param target defines the target animation or animation name
  10487. * @param from defines from where the animation should start (animation frame)
  10488. * @param end defines where the animation should stop (animation frame)
  10489. * @param loop defines if the animation should loop or stop after the first play
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action and play the animation.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to stop an animation once triggered.
  10508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10509. */
  10510. export class StopAnimationAction extends Action {
  10511. private _target;
  10512. /**
  10513. * Instantiate the action
  10514. * @param triggerOptions defines the trigger options
  10515. * @param target defines the target animation or animation name
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, condition?: Condition);
  10519. /** @hidden */
  10520. _prepare(): void;
  10521. /**
  10522. * Execute the action and stop the animation.
  10523. */
  10524. execute(): void;
  10525. /**
  10526. * Serializes the actions and its related information.
  10527. * @param parent defines the object to serialize in
  10528. * @returns the serialized object
  10529. */
  10530. serialize(parent: any): any;
  10531. }
  10532. /**
  10533. * This defines an action responsible that does nothing once triggered.
  10534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10535. */
  10536. export class DoNothingAction extends Action {
  10537. /**
  10538. * Instantiate the action
  10539. * @param triggerOptions defines the trigger options
  10540. * @param condition defines the trigger related conditions
  10541. */
  10542. constructor(triggerOptions?: any, condition?: Condition);
  10543. /**
  10544. * Execute the action and do nothing.
  10545. */
  10546. execute(): void;
  10547. /**
  10548. * Serializes the actions and its related information.
  10549. * @param parent defines the object to serialize in
  10550. * @returns the serialized object
  10551. */
  10552. serialize(parent: any): any;
  10553. }
  10554. /**
  10555. * This defines an action responsible to trigger several actions once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class CombineAction extends Action {
  10559. /**
  10560. * The list of aggregated animations to run.
  10561. */
  10562. children: Action[];
  10563. /**
  10564. * Instantiate the action
  10565. * @param triggerOptions defines the trigger options
  10566. * @param children defines the list of aggregated animations to run
  10567. * @param condition defines the trigger related conditions
  10568. */
  10569. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10570. /** @hidden */
  10571. _prepare(): void;
  10572. /**
  10573. * Execute the action and executes all the aggregated actions.
  10574. */
  10575. execute(evt: ActionEvent): void;
  10576. /**
  10577. * Serializes the actions and its related information.
  10578. * @param parent defines the object to serialize in
  10579. * @returns the serialized object
  10580. */
  10581. serialize(parent: any): any;
  10582. }
  10583. /**
  10584. * This defines an action responsible to run code (external event) once triggered.
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10586. */
  10587. export class ExecuteCodeAction extends Action {
  10588. /**
  10589. * The callback function to run.
  10590. */
  10591. func: (evt: ActionEvent) => void;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param func defines the callback function to run
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10599. /**
  10600. * Execute the action and run the attached code.
  10601. */
  10602. execute(evt: ActionEvent): void;
  10603. }
  10604. /**
  10605. * This defines an action responsible to set the parent property of the target once triggered.
  10606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10607. */
  10608. export class SetParentAction extends Action {
  10609. private _parent;
  10610. private _target;
  10611. /**
  10612. * Instantiate the action
  10613. * @param triggerOptions defines the trigger options
  10614. * @param target defines the target containing the parent property
  10615. * @param parent defines from where the animation should start (animation frame)
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the parent property.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. }
  10633. declare module BABYLON {
  10634. /**
  10635. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10636. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10638. */
  10639. export class ActionManager extends AbstractActionManager {
  10640. /**
  10641. * Nothing
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10643. */
  10644. static readonly NothingTrigger: number;
  10645. /**
  10646. * On pick
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly OnPickTrigger: number;
  10650. /**
  10651. * On left pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnLeftPickTrigger: number;
  10655. /**
  10656. * On right pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnRightPickTrigger: number;
  10660. /**
  10661. * On center pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnCenterPickTrigger: number;
  10665. /**
  10666. * On pick down
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnPickDownTrigger: number;
  10670. /**
  10671. * On double pick
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnDoublePickTrigger: number;
  10675. /**
  10676. * On pick up
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickUpTrigger: number;
  10680. /**
  10681. * On pick out.
  10682. * This trigger will only be raised if you also declared a OnPickDown
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickOutTrigger: number;
  10686. /**
  10687. * On long press
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnLongPressTrigger: number;
  10691. /**
  10692. * On pointer over
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPointerOverTrigger: number;
  10696. /**
  10697. * On pointer out
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOutTrigger: number;
  10701. /**
  10702. * On every frame
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnEveryFrameTrigger: number;
  10706. /**
  10707. * On intersection enter
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnIntersectionEnterTrigger: number;
  10711. /**
  10712. * On intersection exit
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionExitTrigger: number;
  10716. /**
  10717. * On key down
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnKeyDownTrigger: number;
  10721. /**
  10722. * On key up
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyUpTrigger: number;
  10726. private _scene;
  10727. /**
  10728. * Creates a new action manager
  10729. * @param scene defines the hosting scene
  10730. */
  10731. constructor(scene: Scene);
  10732. /**
  10733. * Releases all associated resources
  10734. */
  10735. dispose(): void;
  10736. /**
  10737. * Gets hosting scene
  10738. * @returns the hosting scene
  10739. */
  10740. getScene(): Scene;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Does this action manager has pointer triggers
  10764. */
  10765. readonly hasPointerTriggers: boolean;
  10766. /**
  10767. * Does this action manager has pick triggers
  10768. */
  10769. readonly hasPickTriggers: boolean;
  10770. /**
  10771. * Registers an action to this action manager
  10772. * @param action defines the action to be registered
  10773. * @return the action amended (prepared) after registration
  10774. */
  10775. registerAction(action: IAction): Nullable<IAction>;
  10776. /**
  10777. * Unregisters an action to this action manager
  10778. * @param action defines the action to be unregistered
  10779. * @return a boolean indicating whether the action has been unregistered
  10780. */
  10781. unregisterAction(action: IAction): Boolean;
  10782. /**
  10783. * Process a specific trigger
  10784. * @param trigger defines the trigger to process
  10785. * @param evt defines the event details to be processed
  10786. */
  10787. processTrigger(trigger: number, evt?: IActionEvent): void;
  10788. /** @hidden */
  10789. _getEffectiveTarget(target: any, propertyPath: string): any;
  10790. /** @hidden */
  10791. _getProperty(propertyPath: string): string;
  10792. /**
  10793. * Serialize this manager to a JSON object
  10794. * @param name defines the property name to store this manager
  10795. * @returns a JSON representation of this manager
  10796. */
  10797. serialize(name: string): any;
  10798. /**
  10799. * Creates a new ActionManager from a JSON data
  10800. * @param parsedActions defines the JSON data to read from
  10801. * @param object defines the hosting mesh
  10802. * @param scene defines the hosting scene
  10803. */
  10804. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10805. /**
  10806. * Get a trigger name by index
  10807. * @param trigger defines the trigger index
  10808. * @returns a trigger name
  10809. */
  10810. static GetTriggerName(trigger: number): string;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * Class representing a ray with position and direction
  10816. */
  10817. export class Ray {
  10818. /** origin point */
  10819. origin: Vector3;
  10820. /** direction */
  10821. direction: Vector3;
  10822. /** length of the ray */
  10823. length: number;
  10824. private static readonly TmpVector3;
  10825. private _tmpRay;
  10826. /**
  10827. * Creates a new ray
  10828. * @param origin origin point
  10829. * @param direction direction
  10830. * @param length length of the ray
  10831. */
  10832. constructor(
  10833. /** origin point */
  10834. origin: Vector3,
  10835. /** direction */
  10836. direction: Vector3,
  10837. /** length of the ray */
  10838. length?: number);
  10839. /**
  10840. * Checks if the ray intersects a box
  10841. * @param minimum bound of the box
  10842. * @param maximum bound of the box
  10843. * @param intersectionTreshold extra extend to be added to the box in all direction
  10844. * @returns if the box was hit
  10845. */
  10846. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10847. /**
  10848. * Checks if the ray intersects a box
  10849. * @param box the bounding box to check
  10850. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10851. * @returns if the box was hit
  10852. */
  10853. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10854. /**
  10855. * If the ray hits a sphere
  10856. * @param sphere the bounding sphere to check
  10857. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10858. * @returns true if it hits the sphere
  10859. */
  10860. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10861. /**
  10862. * If the ray hits a triange
  10863. * @param vertex0 triangle vertex
  10864. * @param vertex1 triangle vertex
  10865. * @param vertex2 triangle vertex
  10866. * @returns intersection information if hit
  10867. */
  10868. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10869. /**
  10870. * Checks if ray intersects a plane
  10871. * @param plane the plane to check
  10872. * @returns the distance away it was hit
  10873. */
  10874. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10875. /**
  10876. * Calculate the intercept of a ray on a given axis
  10877. * @param axis to check 'x' | 'y' | 'z'
  10878. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10879. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10880. */
  10881. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10882. /**
  10883. * Checks if ray intersects a mesh
  10884. * @param mesh the mesh to check
  10885. * @param fastCheck if only the bounding box should checked
  10886. * @returns picking info of the intersecton
  10887. */
  10888. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10889. /**
  10890. * Checks if ray intersects a mesh
  10891. * @param meshes the meshes to check
  10892. * @param fastCheck if only the bounding box should checked
  10893. * @param results array to store result in
  10894. * @returns Array of picking infos
  10895. */
  10896. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10897. private _comparePickingInfo;
  10898. private static smallnum;
  10899. private static rayl;
  10900. /**
  10901. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10902. * @param sega the first point of the segment to test the intersection against
  10903. * @param segb the second point of the segment to test the intersection against
  10904. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10905. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10906. */
  10907. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10908. /**
  10909. * Update the ray from viewport position
  10910. * @param x position
  10911. * @param y y position
  10912. * @param viewportWidth viewport width
  10913. * @param viewportHeight viewport height
  10914. * @param world world matrix
  10915. * @param view view matrix
  10916. * @param projection projection matrix
  10917. * @returns this ray updated
  10918. */
  10919. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10920. /**
  10921. * Creates a ray with origin and direction of 0,0,0
  10922. * @returns the new ray
  10923. */
  10924. static Zero(): Ray;
  10925. /**
  10926. * Creates a new ray from screen space and viewport
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns new ray
  10935. */
  10936. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * 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
  10939. * transformed to the given world matrix.
  10940. * @param origin The origin point
  10941. * @param end The end point
  10942. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10943. * @returns the new ray
  10944. */
  10945. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10946. /**
  10947. * Transforms a ray by a matrix
  10948. * @param ray ray to transform
  10949. * @param matrix matrix to apply
  10950. * @returns the resulting new ray
  10951. */
  10952. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10953. /**
  10954. * Transforms a ray by a matrix
  10955. * @param ray ray to transform
  10956. * @param matrix matrix to apply
  10957. * @param result ray to store result in
  10958. */
  10959. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10960. /**
  10961. * Unproject a ray from screen space to object space
  10962. * @param sourceX defines the screen space x coordinate to use
  10963. * @param sourceY defines the screen space y coordinate to use
  10964. * @param viewportWidth defines the current width of the viewport
  10965. * @param viewportHeight defines the current height of the viewport
  10966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10967. * @param view defines the view matrix to use
  10968. * @param projection defines the projection matrix to use
  10969. */
  10970. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10971. }
  10972. /**
  10973. * Type used to define predicate used to select faces when a mesh intersection is detected
  10974. */
  10975. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10976. interface Scene {
  10977. /** @hidden */
  10978. _tempPickingRay: Nullable<Ray>;
  10979. /** @hidden */
  10980. _cachedRayForTransform: Ray;
  10981. /** @hidden */
  10982. _pickWithRayInverseMatrix: Matrix;
  10983. /** @hidden */
  10984. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10985. /** @hidden */
  10986. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10987. }
  10988. }
  10989. declare module BABYLON {
  10990. /**
  10991. * Groups all the scene component constants in one place to ease maintenance.
  10992. * @hidden
  10993. */
  10994. export class SceneComponentConstants {
  10995. static readonly NAME_EFFECTLAYER: string;
  10996. static readonly NAME_LAYER: string;
  10997. static readonly NAME_LENSFLARESYSTEM: string;
  10998. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10999. static readonly NAME_PARTICLESYSTEM: string;
  11000. static readonly NAME_GAMEPAD: string;
  11001. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11002. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11003. static readonly NAME_DEPTHRENDERER: string;
  11004. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11005. static readonly NAME_SPRITE: string;
  11006. static readonly NAME_OUTLINERENDERER: string;
  11007. static readonly NAME_PROCEDURALTEXTURE: string;
  11008. static readonly NAME_SHADOWGENERATOR: string;
  11009. static readonly NAME_OCTREE: string;
  11010. static readonly NAME_PHYSICSENGINE: string;
  11011. static readonly NAME_AUDIO: string;
  11012. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11013. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11014. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11015. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11016. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11017. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11018. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11019. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11020. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11021. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11022. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11023. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11024. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11025. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11026. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11027. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11028. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11029. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11030. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11031. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11032. static readonly STEP_AFTERRENDER_AUDIO: number;
  11033. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11034. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11035. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11036. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11037. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11038. static readonly STEP_POINTERMOVE_SPRITE: number;
  11039. static readonly STEP_POINTERDOWN_SPRITE: number;
  11040. static readonly STEP_POINTERUP_SPRITE: number;
  11041. }
  11042. /**
  11043. * This represents a scene component.
  11044. *
  11045. * This is used to decouple the dependency the scene is having on the different workloads like
  11046. * layers, post processes...
  11047. */
  11048. export interface ISceneComponent {
  11049. /**
  11050. * The name of the component. Each component must have a unique name.
  11051. */
  11052. name: string;
  11053. /**
  11054. * The scene the component belongs to.
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Register the component to one instance of a scene.
  11059. */
  11060. register(): void;
  11061. /**
  11062. * Rebuilds the elements related to this component in case of
  11063. * context lost for instance.
  11064. */
  11065. rebuild(): void;
  11066. /**
  11067. * Disposes the component and the associated ressources.
  11068. */
  11069. dispose(): void;
  11070. }
  11071. /**
  11072. * This represents a SERIALIZABLE scene component.
  11073. *
  11074. * This extends Scene Component to add Serialization methods on top.
  11075. */
  11076. export interface ISceneSerializableComponent extends ISceneComponent {
  11077. /**
  11078. * Adds all the elements from the container to the scene
  11079. * @param container the container holding the elements
  11080. */
  11081. addFromContainer(container: AbstractScene): void;
  11082. /**
  11083. * Removes all the elements in the container from the scene
  11084. * @param container contains the elements to remove
  11085. * @param dispose if the removed element should be disposed (default: false)
  11086. */
  11087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11088. /**
  11089. * Serializes the component data to the specified json object
  11090. * @param serializationObject The object to serialize to
  11091. */
  11092. serialize(serializationObject: any): void;
  11093. }
  11094. /**
  11095. * Strong typing of a Mesh related stage step action
  11096. */
  11097. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11098. /**
  11099. * Strong typing of a Evaluate Sub Mesh related stage step action
  11100. */
  11101. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11102. /**
  11103. * Strong typing of a Active Mesh related stage step action
  11104. */
  11105. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11106. /**
  11107. * Strong typing of a Camera related stage step action
  11108. */
  11109. export type CameraStageAction = (camera: Camera) => void;
  11110. /**
  11111. * Strong typing of a Camera Frame buffer related stage step action
  11112. */
  11113. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11114. /**
  11115. * Strong typing of a Render Target related stage step action
  11116. */
  11117. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11118. /**
  11119. * Strong typing of a RenderingGroup related stage step action
  11120. */
  11121. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11122. /**
  11123. * Strong typing of a Mesh Render related stage step action
  11124. */
  11125. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11126. /**
  11127. * Strong typing of a simple stage step action
  11128. */
  11129. export type SimpleStageAction = () => void;
  11130. /**
  11131. * Strong typing of a render target action.
  11132. */
  11133. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11134. /**
  11135. * Strong typing of a pointer move action.
  11136. */
  11137. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11138. /**
  11139. * Strong typing of a pointer up/down action.
  11140. */
  11141. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11142. /**
  11143. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11144. * @hidden
  11145. */
  11146. export class Stage<T extends Function> extends Array<{
  11147. index: number;
  11148. component: ISceneComponent;
  11149. action: T;
  11150. }> {
  11151. /**
  11152. * Hide ctor from the rest of the world.
  11153. * @param items The items to add.
  11154. */
  11155. private constructor();
  11156. /**
  11157. * Creates a new Stage.
  11158. * @returns A new instance of a Stage
  11159. */
  11160. static Create<T extends Function>(): Stage<T>;
  11161. /**
  11162. * Registers a step in an ordered way in the targeted stage.
  11163. * @param index Defines the position to register the step in
  11164. * @param component Defines the component attached to the step
  11165. * @param action Defines the action to launch during the step
  11166. */
  11167. registerStep(index: number, component: ISceneComponent, action: T): void;
  11168. /**
  11169. * Clears all the steps from the stage.
  11170. */
  11171. clear(): void;
  11172. }
  11173. }
  11174. declare module BABYLON {
  11175. interface Scene {
  11176. /** @hidden */
  11177. _pointerOverSprite: Nullable<Sprite>;
  11178. /** @hidden */
  11179. _pickedDownSprite: Nullable<Sprite>;
  11180. /** @hidden */
  11181. _tempSpritePickingRay: Nullable<Ray>;
  11182. /**
  11183. * All of the sprite managers added to this scene
  11184. * @see http://doc.babylonjs.com/babylon101/sprites
  11185. */
  11186. spriteManagers: Array<ISpriteManager>;
  11187. /**
  11188. * An event triggered when sprites rendering is about to start
  11189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11190. */
  11191. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11192. /**
  11193. * An event triggered when sprites rendering is done
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onAfterSpritesRenderingObservable: Observable<Scene>;
  11197. /** @hidden */
  11198. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11199. /** Launch a ray to try to pick a sprite in the scene
  11200. * @param x position on screen
  11201. * @param y position on screen
  11202. * @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
  11203. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11204. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11205. * @returns a PickingInfo
  11206. */
  11207. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11208. /** Use the given ray to pick a sprite in the scene
  11209. * @param ray The ray (in world space) to use to pick meshes
  11210. * @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
  11211. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11213. * @returns a PickingInfo
  11214. */
  11215. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /**
  11217. * Force the sprite under the pointer
  11218. * @param sprite defines the sprite to use
  11219. */
  11220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11221. /**
  11222. * Gets the sprite under the pointer
  11223. * @returns a Sprite or null if no sprite is under the pointer
  11224. */
  11225. getPointerOverSprite(): Nullable<Sprite>;
  11226. }
  11227. /**
  11228. * Defines the sprite scene component responsible to manage sprites
  11229. * in a given scene.
  11230. */
  11231. export class SpriteSceneComponent implements ISceneComponent {
  11232. /**
  11233. * The component name helpfull to identify the component in the list of scene components.
  11234. */
  11235. readonly name: string;
  11236. /**
  11237. * The scene the component belongs to.
  11238. */
  11239. scene: Scene;
  11240. /** @hidden */
  11241. private _spritePredicate;
  11242. /**
  11243. * Creates a new instance of the component for the given scene
  11244. * @param scene Defines the scene to register the component in
  11245. */
  11246. constructor(scene: Scene);
  11247. /**
  11248. * Registers the component in a given scene
  11249. */
  11250. register(): void;
  11251. /**
  11252. * Rebuilds the elements related to this component in case of
  11253. * context lost for instance.
  11254. */
  11255. rebuild(): void;
  11256. /**
  11257. * Disposes the component and the associated ressources.
  11258. */
  11259. dispose(): void;
  11260. private _pickSpriteButKeepRay;
  11261. private _pointerMove;
  11262. private _pointerDown;
  11263. private _pointerUp;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogFragmentDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var fogFragment: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /** @hidden */
  11282. export var spritesPixelShader: {
  11283. name: string;
  11284. shader: string;
  11285. };
  11286. }
  11287. declare module BABYLON {
  11288. /** @hidden */
  11289. export var fogVertexDeclaration: {
  11290. name: string;
  11291. shader: string;
  11292. };
  11293. }
  11294. declare module BABYLON {
  11295. /** @hidden */
  11296. export var spritesVertexShader: {
  11297. name: string;
  11298. shader: string;
  11299. };
  11300. }
  11301. declare module BABYLON {
  11302. /**
  11303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11304. */
  11305. export interface ISpriteManager extends IDisposable {
  11306. /**
  11307. * Restricts the camera to viewing objects with the same layerMask.
  11308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11309. */
  11310. layerMask: number;
  11311. /**
  11312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11313. */
  11314. isPickable: boolean;
  11315. /**
  11316. * Specifies the rendering group id for this mesh (0 by default)
  11317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11318. */
  11319. renderingGroupId: number;
  11320. /**
  11321. * Defines the list of sprites managed by the manager.
  11322. */
  11323. sprites: Array<Sprite>;
  11324. /**
  11325. * Tests the intersection of a sprite with a specific ray.
  11326. * @param ray The ray we are sending to test the collision
  11327. * @param camera The camera space we are sending rays in
  11328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11330. * @returns picking info or null.
  11331. */
  11332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11333. /**
  11334. * Renders the list of sprites on screen.
  11335. */
  11336. render(): void;
  11337. }
  11338. /**
  11339. * Class used to manage multiple sprites on the same spritesheet
  11340. * @see http://doc.babylonjs.com/babylon101/sprites
  11341. */
  11342. export class SpriteManager implements ISpriteManager {
  11343. /** defines the manager's name */
  11344. name: string;
  11345. /** Gets the list of sprites */
  11346. sprites: Sprite[];
  11347. /** Gets or sets the rendering group id (0 by default) */
  11348. renderingGroupId: number;
  11349. /** Gets or sets camera layer mask */
  11350. layerMask: number;
  11351. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11352. fogEnabled: boolean;
  11353. /** Gets or sets a boolean indicating if the sprites are pickable */
  11354. isPickable: boolean;
  11355. /** Defines the default width of a cell in the spritesheet */
  11356. cellWidth: number;
  11357. /** Defines the default height of a cell in the spritesheet */
  11358. cellHeight: number;
  11359. /**
  11360. * An event triggered when the manager is disposed.
  11361. */
  11362. onDisposeObservable: Observable<SpriteManager>;
  11363. private _onDisposeObserver;
  11364. /**
  11365. * Callback called when the manager is disposed
  11366. */
  11367. onDispose: () => void;
  11368. private _capacity;
  11369. private _spriteTexture;
  11370. private _epsilon;
  11371. private _scene;
  11372. private _vertexData;
  11373. private _buffer;
  11374. private _vertexBuffers;
  11375. private _indexBuffer;
  11376. private _effectBase;
  11377. private _effectFog;
  11378. /**
  11379. * Gets or sets the spritesheet texture
  11380. */
  11381. texture: Texture;
  11382. /**
  11383. * Creates a new sprite manager
  11384. * @param name defines the manager's name
  11385. * @param imgUrl defines the sprite sheet url
  11386. * @param capacity defines the maximum allowed number of sprites
  11387. * @param cellSize defines the size of a sprite cell
  11388. * @param scene defines the hosting scene
  11389. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11390. * @param samplingMode defines the smapling mode to use with spritesheet
  11391. */
  11392. constructor(
  11393. /** defines the manager's name */
  11394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11395. private _appendSpriteVertex;
  11396. /**
  11397. * Intersects the sprites with a ray
  11398. * @param ray defines the ray to intersect with
  11399. * @param camera defines the current active camera
  11400. * @param predicate defines a predicate used to select candidate sprites
  11401. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11402. * @returns null if no hit or a PickingInfo
  11403. */
  11404. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11405. /**
  11406. * Render all child sprites
  11407. */
  11408. render(): void;
  11409. /**
  11410. * Release associated resources
  11411. */
  11412. dispose(): void;
  11413. }
  11414. }
  11415. declare module BABYLON {
  11416. /**
  11417. * Class used to represent a sprite
  11418. * @see http://doc.babylonjs.com/babylon101/sprites
  11419. */
  11420. export class Sprite {
  11421. /** defines the name */
  11422. name: string;
  11423. /** Gets or sets the current world position */
  11424. position: Vector3;
  11425. /** Gets or sets the main color */
  11426. color: Color4;
  11427. /** Gets or sets the width */
  11428. width: number;
  11429. /** Gets or sets the height */
  11430. height: number;
  11431. /** Gets or sets rotation angle */
  11432. angle: number;
  11433. /** Gets or sets the cell index in the sprite sheet */
  11434. cellIndex: number;
  11435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11436. invertU: number;
  11437. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11438. invertV: number;
  11439. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11440. disposeWhenFinishedAnimating: boolean;
  11441. /** Gets the list of attached animations */
  11442. animations: Animation[];
  11443. /** Gets or sets a boolean indicating if the sprite can be picked */
  11444. isPickable: boolean;
  11445. /**
  11446. * Gets or sets the associated action manager
  11447. */
  11448. actionManager: Nullable<ActionManager>;
  11449. private _animationStarted;
  11450. private _loopAnimation;
  11451. private _fromIndex;
  11452. private _toIndex;
  11453. private _delay;
  11454. private _direction;
  11455. private _manager;
  11456. private _time;
  11457. private _onAnimationEnd;
  11458. /**
  11459. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11460. */
  11461. isVisible: boolean;
  11462. /**
  11463. * Gets or sets the sprite size
  11464. */
  11465. size: number;
  11466. /**
  11467. * Creates a new Sprite
  11468. * @param name defines the name
  11469. * @param manager defines the manager
  11470. */
  11471. constructor(
  11472. /** defines the name */
  11473. name: string, manager: ISpriteManager);
  11474. /**
  11475. * Starts an animation
  11476. * @param from defines the initial key
  11477. * @param to defines the end key
  11478. * @param loop defines if the animation must loop
  11479. * @param delay defines the start delay (in ms)
  11480. * @param onAnimationEnd defines a callback to call when animation ends
  11481. */
  11482. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11483. /** Stops current animation (if any) */
  11484. stopAnimation(): void;
  11485. /** @hidden */
  11486. _animate(deltaTime: number): void;
  11487. /** Release associated resources */
  11488. dispose(): void;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /**
  11493. * Information about the result of picking within a scene
  11494. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11495. */
  11496. export class PickingInfo {
  11497. /** @hidden */
  11498. _pickingUnavailable: boolean;
  11499. /**
  11500. * If the pick collided with an object
  11501. */
  11502. hit: boolean;
  11503. /**
  11504. * Distance away where the pick collided
  11505. */
  11506. distance: number;
  11507. /**
  11508. * The location of pick collision
  11509. */
  11510. pickedPoint: Nullable<Vector3>;
  11511. /**
  11512. * The mesh corresponding the the pick collision
  11513. */
  11514. pickedMesh: Nullable<AbstractMesh>;
  11515. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11516. bu: number;
  11517. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11518. bv: number;
  11519. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11520. faceId: number;
  11521. /** Id of the the submesh that was picked */
  11522. subMeshId: number;
  11523. /** If a sprite was picked, this will be the sprite the pick collided with */
  11524. pickedSprite: Nullable<Sprite>;
  11525. /**
  11526. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11527. */
  11528. originMesh: Nullable<AbstractMesh>;
  11529. /**
  11530. * The ray that was used to perform the picking.
  11531. */
  11532. ray: Nullable<Ray>;
  11533. /**
  11534. * Gets the normal correspodning to the face the pick collided with
  11535. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11536. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11537. * @returns The normal correspodning to the face the pick collided with
  11538. */
  11539. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11540. /**
  11541. * Gets the texture coordinates of where the pick occured
  11542. * @returns the vector containing the coordnates of the texture
  11543. */
  11544. getTextureCoordinates(): Nullable<Vector2>;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Gather the list of pointer event types as constants.
  11550. */
  11551. export class PointerEventTypes {
  11552. /**
  11553. * 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.
  11554. */
  11555. static readonly POINTERDOWN: number;
  11556. /**
  11557. * The pointerup event is fired when a pointer is no longer active.
  11558. */
  11559. static readonly POINTERUP: number;
  11560. /**
  11561. * The pointermove event is fired when a pointer changes coordinates.
  11562. */
  11563. static readonly POINTERMOVE: number;
  11564. /**
  11565. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11566. */
  11567. static readonly POINTERWHEEL: number;
  11568. /**
  11569. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11570. */
  11571. static readonly POINTERPICK: number;
  11572. /**
  11573. * The pointertap event is fired when a the object has been touched and released without drag.
  11574. */
  11575. static readonly POINTERTAP: number;
  11576. /**
  11577. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11578. */
  11579. static readonly POINTERDOUBLETAP: number;
  11580. }
  11581. /**
  11582. * Base class of pointer info types.
  11583. */
  11584. export class PointerInfoBase {
  11585. /**
  11586. * Defines the type of event (PointerEventTypes)
  11587. */
  11588. type: number;
  11589. /**
  11590. * Defines the related dom event
  11591. */
  11592. event: PointerEvent | MouseWheelEvent;
  11593. /**
  11594. * Instantiates the base class of pointers info.
  11595. * @param type Defines the type of event (PointerEventTypes)
  11596. * @param event Defines the related dom event
  11597. */
  11598. constructor(
  11599. /**
  11600. * Defines the type of event (PointerEventTypes)
  11601. */
  11602. type: number,
  11603. /**
  11604. * Defines the related dom event
  11605. */
  11606. event: PointerEvent | MouseWheelEvent);
  11607. }
  11608. /**
  11609. * This class is used to store pointer related info for the onPrePointerObservable event.
  11610. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11611. */
  11612. export class PointerInfoPre extends PointerInfoBase {
  11613. /**
  11614. * Ray from a pointer if availible (eg. 6dof controller)
  11615. */
  11616. ray: Nullable<Ray>;
  11617. /**
  11618. * Defines the local position of the pointer on the canvas.
  11619. */
  11620. localPosition: Vector2;
  11621. /**
  11622. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11623. */
  11624. skipOnPointerObservable: boolean;
  11625. /**
  11626. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11627. * @param type Defines the type of event (PointerEventTypes)
  11628. * @param event Defines the related dom event
  11629. * @param localX Defines the local x coordinates of the pointer when the event occured
  11630. * @param localY Defines the local y coordinates of the pointer when the event occured
  11631. */
  11632. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11633. }
  11634. /**
  11635. * This type contains all the data related to a pointer event in Babylon.js.
  11636. * 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.
  11637. */
  11638. export class PointerInfo extends PointerInfoBase {
  11639. /**
  11640. * Defines the picking info associated to the info (if any)\
  11641. */
  11642. pickInfo: Nullable<PickingInfo>;
  11643. /**
  11644. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. * @param pickInfo Defines the picking info associated to the info (if any)\
  11648. */
  11649. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11650. /**
  11651. * Defines the picking info associated to the info (if any)\
  11652. */
  11653. pickInfo: Nullable<PickingInfo>);
  11654. }
  11655. /**
  11656. * Data relating to a touch event on the screen.
  11657. */
  11658. export interface PointerTouch {
  11659. /**
  11660. * X coordinate of touch.
  11661. */
  11662. x: number;
  11663. /**
  11664. * Y coordinate of touch.
  11665. */
  11666. y: number;
  11667. /**
  11668. * Id of touch. Unique for each finger.
  11669. */
  11670. pointerId: number;
  11671. /**
  11672. * Event type passed from DOM.
  11673. */
  11674. type: any;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. /**
  11679. * Manage the mouse inputs to control the movement of a free camera.
  11680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11681. */
  11682. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11683. /**
  11684. * Define if touch is enabled in the mouse input
  11685. */
  11686. touchEnabled: boolean;
  11687. /**
  11688. * Defines the camera the input is attached to.
  11689. */
  11690. camera: FreeCamera;
  11691. /**
  11692. * Defines the buttons associated with the input to handle camera move.
  11693. */
  11694. buttons: number[];
  11695. /**
  11696. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11697. */
  11698. angularSensibility: number;
  11699. private _pointerInput;
  11700. private _onMouseMove;
  11701. private _observer;
  11702. private previousPosition;
  11703. /**
  11704. * Observable for when a pointer move event occurs containing the move offset
  11705. */
  11706. onPointerMovedObservable: Observable<{
  11707. offsetX: number;
  11708. offsetY: number;
  11709. }>;
  11710. /**
  11711. * @hidden
  11712. * If the camera should be rotated automatically based on pointer movement
  11713. */
  11714. _allowCameraRotation: boolean;
  11715. /**
  11716. * Manage the mouse inputs to control the movement of a free camera.
  11717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11718. * @param touchEnabled Defines if touch is enabled or not
  11719. */
  11720. constructor(
  11721. /**
  11722. * Define if touch is enabled in the mouse input
  11723. */
  11724. touchEnabled?: boolean);
  11725. /**
  11726. * Attach the input controls to a specific dom element to get the input from.
  11727. * @param element Defines the element the controls should be listened from
  11728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11729. */
  11730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11731. /**
  11732. * Called on JS contextmenu event.
  11733. * Override this method to provide functionality.
  11734. */
  11735. protected onContextMenu(evt: PointerEvent): void;
  11736. /**
  11737. * Detach the current controls from the specified dom element.
  11738. * @param element Defines the element to stop listening the inputs from
  11739. */
  11740. detachControl(element: Nullable<HTMLElement>): void;
  11741. /**
  11742. * Gets the class name of the current intput.
  11743. * @returns the class name
  11744. */
  11745. getClassName(): string;
  11746. /**
  11747. * Get the friendly name associated with the input class.
  11748. * @returns the input friendly name
  11749. */
  11750. getSimpleName(): string;
  11751. }
  11752. }
  11753. declare module BABYLON {
  11754. /**
  11755. * Manage the touch inputs to control the movement of a free camera.
  11756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11757. */
  11758. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11759. /**
  11760. * Defines the camera the input is attached to.
  11761. */
  11762. camera: FreeCamera;
  11763. /**
  11764. * Defines the touch sensibility for rotation.
  11765. * The higher the faster.
  11766. */
  11767. touchAngularSensibility: number;
  11768. /**
  11769. * Defines the touch sensibility for move.
  11770. * The higher the faster.
  11771. */
  11772. touchMoveSensibility: number;
  11773. private _offsetX;
  11774. private _offsetY;
  11775. private _pointerPressed;
  11776. private _pointerInput;
  11777. private _observer;
  11778. private _onLostFocus;
  11779. /**
  11780. * Attach the input controls to a specific dom element to get the input from.
  11781. * @param element Defines the element the controls should be listened from
  11782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11783. */
  11784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11785. /**
  11786. * Detach the current controls from the specified dom element.
  11787. * @param element Defines the element to stop listening the inputs from
  11788. */
  11789. detachControl(element: Nullable<HTMLElement>): void;
  11790. /**
  11791. * Update the current camera state depending on the inputs that have been used this frame.
  11792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11793. */
  11794. checkInputs(): void;
  11795. /**
  11796. * Gets the class name of the current intput.
  11797. * @returns the class name
  11798. */
  11799. getClassName(): string;
  11800. /**
  11801. * Get the friendly name associated with the input class.
  11802. * @returns the input friendly name
  11803. */
  11804. getSimpleName(): string;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * Default Inputs manager for the FreeCamera.
  11810. * It groups all the default supported inputs for ease of use.
  11811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11812. */
  11813. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11814. /**
  11815. * @hidden
  11816. */
  11817. _mouseInput: Nullable<FreeCameraMouseInput>;
  11818. /**
  11819. * Instantiates a new FreeCameraInputsManager.
  11820. * @param camera Defines the camera the inputs belong to
  11821. */
  11822. constructor(camera: FreeCamera);
  11823. /**
  11824. * Add keyboard input support to the input manager.
  11825. * @returns the current input manager
  11826. */
  11827. addKeyboard(): FreeCameraInputsManager;
  11828. /**
  11829. * Add mouse input support to the input manager.
  11830. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11831. * @returns the current input manager
  11832. */
  11833. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11834. /**
  11835. * Removes the mouse input support from the manager
  11836. * @returns the current input manager
  11837. */
  11838. removeMouse(): FreeCameraInputsManager;
  11839. /**
  11840. * Add touch input support to the input manager.
  11841. * @returns the current input manager
  11842. */
  11843. addTouch(): FreeCameraInputsManager;
  11844. /**
  11845. * Remove all attached input methods from a camera
  11846. */
  11847. clear(): void;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11853. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11854. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11855. */
  11856. export class FreeCamera extends TargetCamera {
  11857. /**
  11858. * Define the collision ellipsoid of the camera.
  11859. * This is helpful to simulate a camera body like the player body around the camera
  11860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11861. */
  11862. ellipsoid: Vector3;
  11863. /**
  11864. * Define an offset for the position of the ellipsoid around the camera.
  11865. * This can be helpful to determine the center of the body near the gravity center of the body
  11866. * instead of its head.
  11867. */
  11868. ellipsoidOffset: Vector3;
  11869. /**
  11870. * Enable or disable collisions of the camera with the rest of the scene objects.
  11871. */
  11872. checkCollisions: boolean;
  11873. /**
  11874. * Enable or disable gravity on the camera.
  11875. */
  11876. applyGravity: boolean;
  11877. /**
  11878. * Define the input manager associated to the camera.
  11879. */
  11880. inputs: FreeCameraInputsManager;
  11881. /**
  11882. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11883. * Higher values reduce sensitivity.
  11884. */
  11885. /**
  11886. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11887. * Higher values reduce sensitivity.
  11888. */
  11889. angularSensibility: number;
  11890. /**
  11891. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11892. */
  11893. keysUp: number[];
  11894. /**
  11895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11896. */
  11897. keysDown: number[];
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11900. */
  11901. keysLeft: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11904. */
  11905. keysRight: number[];
  11906. /**
  11907. * Event raised when the camera collide with a mesh in the scene.
  11908. */
  11909. onCollide: (collidedMesh: AbstractMesh) => void;
  11910. private _collider;
  11911. private _needMoveForGravity;
  11912. private _oldPosition;
  11913. private _diffPosition;
  11914. private _newPosition;
  11915. /** @hidden */
  11916. _localDirection: Vector3;
  11917. /** @hidden */
  11918. _transformedDirection: Vector3;
  11919. /**
  11920. * Instantiates a Free Camera.
  11921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11922. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11924. * @param name Define the name of the camera in the scene
  11925. * @param position Define the start position of the camera in the scene
  11926. * @param scene Define the scene the camera belongs to
  11927. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11928. */
  11929. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11930. /**
  11931. * Attached controls to the current camera.
  11932. * @param element Defines the element the controls should be listened from
  11933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11934. */
  11935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11936. /**
  11937. * Detach the current controls from the camera.
  11938. * The camera will stop reacting to inputs.
  11939. * @param element Defines the element to stop listening the inputs from
  11940. */
  11941. detachControl(element: HTMLElement): void;
  11942. private _collisionMask;
  11943. /**
  11944. * Define a collision mask to limit the list of object the camera can collide with
  11945. */
  11946. collisionMask: number;
  11947. /** @hidden */
  11948. _collideWithWorld(displacement: Vector3): void;
  11949. private _onCollisionPositionChange;
  11950. /** @hidden */
  11951. _checkInputs(): void;
  11952. /** @hidden */
  11953. _decideIfNeedsToMove(): boolean;
  11954. /** @hidden */
  11955. _updatePosition(): void;
  11956. /**
  11957. * Destroy the camera and release the current resources hold by it.
  11958. */
  11959. dispose(): void;
  11960. /**
  11961. * Gets the current object class name.
  11962. * @return the class name
  11963. */
  11964. getClassName(): string;
  11965. }
  11966. }
  11967. declare module BABYLON {
  11968. /**
  11969. * Represents a gamepad control stick position
  11970. */
  11971. export class StickValues {
  11972. /**
  11973. * The x component of the control stick
  11974. */
  11975. x: number;
  11976. /**
  11977. * The y component of the control stick
  11978. */
  11979. y: number;
  11980. /**
  11981. * Initializes the gamepad x and y control stick values
  11982. * @param x The x component of the gamepad control stick value
  11983. * @param y The y component of the gamepad control stick value
  11984. */
  11985. constructor(
  11986. /**
  11987. * The x component of the control stick
  11988. */
  11989. x: number,
  11990. /**
  11991. * The y component of the control stick
  11992. */
  11993. y: number);
  11994. }
  11995. /**
  11996. * An interface which manages callbacks for gamepad button changes
  11997. */
  11998. export interface GamepadButtonChanges {
  11999. /**
  12000. * Called when a gamepad has been changed
  12001. */
  12002. changed: boolean;
  12003. /**
  12004. * Called when a gamepad press event has been triggered
  12005. */
  12006. pressChanged: boolean;
  12007. /**
  12008. * Called when a touch event has been triggered
  12009. */
  12010. touchChanged: boolean;
  12011. /**
  12012. * Called when a value has changed
  12013. */
  12014. valueChanged: boolean;
  12015. }
  12016. /**
  12017. * Represents a gamepad
  12018. */
  12019. export class Gamepad {
  12020. /**
  12021. * The id of the gamepad
  12022. */
  12023. id: string;
  12024. /**
  12025. * The index of the gamepad
  12026. */
  12027. index: number;
  12028. /**
  12029. * The browser gamepad
  12030. */
  12031. browserGamepad: any;
  12032. /**
  12033. * Specifies what type of gamepad this represents
  12034. */
  12035. type: number;
  12036. private _leftStick;
  12037. private _rightStick;
  12038. /** @hidden */
  12039. _isConnected: boolean;
  12040. private _leftStickAxisX;
  12041. private _leftStickAxisY;
  12042. private _rightStickAxisX;
  12043. private _rightStickAxisY;
  12044. /**
  12045. * Triggered when the left control stick has been changed
  12046. */
  12047. private _onleftstickchanged;
  12048. /**
  12049. * Triggered when the right control stick has been changed
  12050. */
  12051. private _onrightstickchanged;
  12052. /**
  12053. * Represents a gamepad controller
  12054. */
  12055. static GAMEPAD: number;
  12056. /**
  12057. * Represents a generic controller
  12058. */
  12059. static GENERIC: number;
  12060. /**
  12061. * Represents an XBox controller
  12062. */
  12063. static XBOX: number;
  12064. /**
  12065. * Represents a pose-enabled controller
  12066. */
  12067. static POSE_ENABLED: number;
  12068. /**
  12069. * Specifies whether the left control stick should be Y-inverted
  12070. */
  12071. protected _invertLeftStickY: boolean;
  12072. /**
  12073. * Specifies if the gamepad has been connected
  12074. */
  12075. readonly isConnected: boolean;
  12076. /**
  12077. * Initializes the gamepad
  12078. * @param id The id of the gamepad
  12079. * @param index The index of the gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. * @param leftStickX The x component of the left joystick
  12082. * @param leftStickY The y component of the left joystick
  12083. * @param rightStickX The x component of the right joystick
  12084. * @param rightStickY The y component of the right joystick
  12085. */
  12086. constructor(
  12087. /**
  12088. * The id of the gamepad
  12089. */
  12090. id: string,
  12091. /**
  12092. * The index of the gamepad
  12093. */
  12094. index: number,
  12095. /**
  12096. * The browser gamepad
  12097. */
  12098. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12099. /**
  12100. * Callback triggered when the left joystick has changed
  12101. * @param callback
  12102. */
  12103. onleftstickchanged(callback: (values: StickValues) => void): void;
  12104. /**
  12105. * Callback triggered when the right joystick has changed
  12106. * @param callback
  12107. */
  12108. onrightstickchanged(callback: (values: StickValues) => void): void;
  12109. /**
  12110. * Gets the left joystick
  12111. */
  12112. /**
  12113. * Sets the left joystick values
  12114. */
  12115. leftStick: StickValues;
  12116. /**
  12117. * Gets the right joystick
  12118. */
  12119. /**
  12120. * Sets the right joystick value
  12121. */
  12122. rightStick: StickValues;
  12123. /**
  12124. * Updates the gamepad joystick positions
  12125. */
  12126. update(): void;
  12127. /**
  12128. * Disposes the gamepad
  12129. */
  12130. dispose(): void;
  12131. }
  12132. /**
  12133. * Represents a generic gamepad
  12134. */
  12135. export class GenericPad extends Gamepad {
  12136. private _buttons;
  12137. private _onbuttondown;
  12138. private _onbuttonup;
  12139. /**
  12140. * Observable triggered when a button has been pressed
  12141. */
  12142. onButtonDownObservable: Observable<number>;
  12143. /**
  12144. * Observable triggered when a button has been released
  12145. */
  12146. onButtonUpObservable: Observable<number>;
  12147. /**
  12148. * Callback triggered when a button has been pressed
  12149. * @param callback Called when a button has been pressed
  12150. */
  12151. onbuttondown(callback: (buttonPressed: number) => void): void;
  12152. /**
  12153. * Callback triggered when a button has been released
  12154. * @param callback Called when a button has been released
  12155. */
  12156. onbuttonup(callback: (buttonReleased: number) => void): void;
  12157. /**
  12158. * Initializes the generic gamepad
  12159. * @param id The id of the generic gamepad
  12160. * @param index The index of the generic gamepad
  12161. * @param browserGamepad The browser gamepad
  12162. */
  12163. constructor(id: string, index: number, browserGamepad: any);
  12164. private _setButtonValue;
  12165. /**
  12166. * Updates the generic gamepad
  12167. */
  12168. update(): void;
  12169. /**
  12170. * Disposes the generic gamepad
  12171. */
  12172. dispose(): void;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. interface Engine {
  12177. /**
  12178. * Creates a raw texture
  12179. * @param data defines the data to store in the texture
  12180. * @param width defines the width of the texture
  12181. * @param height defines the height of the texture
  12182. * @param format defines the format of the data
  12183. * @param generateMipMaps defines if the engine should generate the mip levels
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12186. * @param compression defines the compression used (null by default)
  12187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12188. * @returns the raw texture inside an InternalTexture
  12189. */
  12190. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12191. /**
  12192. * Update a raw texture
  12193. * @param texture defines the texture to update
  12194. * @param data defines the data to store in the texture
  12195. * @param format defines the format of the data
  12196. * @param invertY defines if data must be stored with Y axis inverted
  12197. */
  12198. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12199. /**
  12200. * Update a raw texture
  12201. * @param texture defines the texture to update
  12202. * @param data defines the data to store in the texture
  12203. * @param format defines the format of the data
  12204. * @param invertY defines if data must be stored with Y axis inverted
  12205. * @param compression defines the compression used (null by default)
  12206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12207. */
  12208. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12209. /**
  12210. * Creates a new raw cube texture
  12211. * @param data defines the array of data to use to create each face
  12212. * @param size defines the size of the textures
  12213. * @param format defines the format of the data
  12214. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12215. * @param generateMipMaps defines if the engine should generate the mip levels
  12216. * @param invertY defines if data must be stored with Y axis inverted
  12217. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12218. * @param compression defines the compression used (null by default)
  12219. * @returns the cube texture as an InternalTexture
  12220. */
  12221. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12222. /**
  12223. * Update a raw cube texture
  12224. * @param texture defines the texture to udpdate
  12225. * @param data defines the data to store
  12226. * @param format defines the data format
  12227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12228. * @param invertY defines if data must be stored with Y axis inverted
  12229. */
  12230. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12231. /**
  12232. * Update a raw cube texture
  12233. * @param texture defines the texture to udpdate
  12234. * @param data defines the data to store
  12235. * @param format defines the data format
  12236. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12237. * @param invertY defines if data must be stored with Y axis inverted
  12238. * @param compression defines the compression used (null by default)
  12239. */
  12240. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12241. /**
  12242. * Update a raw cube texture
  12243. * @param texture defines the texture to udpdate
  12244. * @param data defines the data to store
  12245. * @param format defines the data format
  12246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12247. * @param invertY defines if data must be stored with Y axis inverted
  12248. * @param compression defines the compression used (null by default)
  12249. * @param level defines which level of the texture to update
  12250. */
  12251. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12252. /**
  12253. * Creates a new raw cube texture from a specified url
  12254. * @param url defines the url where the data is located
  12255. * @param scene defines the current scene
  12256. * @param size defines the size of the textures
  12257. * @param format defines the format of the data
  12258. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12259. * @param noMipmap defines if the engine should avoid generating the mip levels
  12260. * @param callback defines a callback used to extract texture data from loaded data
  12261. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12262. * @param onLoad defines a callback called when texture is loaded
  12263. * @param onError defines a callback called if there is an error
  12264. * @returns the cube texture as an InternalTexture
  12265. */
  12266. 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;
  12267. /**
  12268. * Creates a new raw cube texture from a specified url
  12269. * @param url defines the url where the data is located
  12270. * @param scene defines the current scene
  12271. * @param size defines the size of the textures
  12272. * @param format defines the format of the data
  12273. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12274. * @param noMipmap defines if the engine should avoid generating the mip levels
  12275. * @param callback defines a callback used to extract texture data from loaded data
  12276. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12277. * @param onLoad defines a callback called when texture is loaded
  12278. * @param onError defines a callback called if there is an error
  12279. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12280. * @param invertY defines if data must be stored with Y axis inverted
  12281. * @returns the cube texture as an InternalTexture
  12282. */
  12283. 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;
  12284. /**
  12285. * Creates a new raw 3D texture
  12286. * @param data defines the data used to create the texture
  12287. * @param width defines the width of the texture
  12288. * @param height defines the height of the texture
  12289. * @param depth defines the depth of the texture
  12290. * @param format defines the format of the texture
  12291. * @param generateMipMaps defines if the engine must generate mip levels
  12292. * @param invertY defines if data must be stored with Y axis inverted
  12293. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12294. * @param compression defines the compressed used (can be null)
  12295. * @param textureType defines the compressed used (can be null)
  12296. * @returns a new raw 3D texture (stored in an InternalTexture)
  12297. */
  12298. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12299. /**
  12300. * Update a raw 3D texture
  12301. * @param texture defines the texture to update
  12302. * @param data defines the data to store
  12303. * @param format defines the data format
  12304. * @param invertY defines if data must be stored with Y axis inverted
  12305. */
  12306. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12307. /**
  12308. * Update a raw 3D texture
  12309. * @param texture defines the texture to update
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param invertY defines if data must be stored with Y axis inverted
  12313. * @param compression defines the used compression (can be null)
  12314. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12315. */
  12316. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Raw texture can help creating a texture directly from an array of data.
  12322. * This can be super useful if you either get the data from an uncompressed source or
  12323. * if you wish to create your texture pixel by pixel.
  12324. */
  12325. export class RawTexture extends Texture {
  12326. /**
  12327. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12328. */
  12329. format: number;
  12330. private _engine;
  12331. /**
  12332. * Instantiates a new RawTexture.
  12333. * Raw texture can help creating a texture directly from an array of data.
  12334. * This can be super useful if you either get the data from an uncompressed source or
  12335. * if you wish to create your texture pixel by pixel.
  12336. * @param data define the array of data to use to create the texture
  12337. * @param width define the width of the texture
  12338. * @param height define the height of the texture
  12339. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12340. * @param scene define the scene the texture belongs to
  12341. * @param generateMipMaps define whether mip maps should be generated or not
  12342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12345. */
  12346. constructor(data: ArrayBufferView, width: number, height: number,
  12347. /**
  12348. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12349. */
  12350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12351. /**
  12352. * Updates the texture underlying data.
  12353. * @param data Define the new data of the texture
  12354. */
  12355. update(data: ArrayBufferView): void;
  12356. /**
  12357. * Creates a luminance texture from some data.
  12358. * @param data Define the texture data
  12359. * @param width Define the width of the texture
  12360. * @param height Define the height of the texture
  12361. * @param scene Define the scene the texture belongs to
  12362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12365. * @returns the luminance texture
  12366. */
  12367. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12368. /**
  12369. * Creates a luminance alpha texture from some data.
  12370. * @param data Define the texture data
  12371. * @param width Define the width of the texture
  12372. * @param height Define the height of the texture
  12373. * @param scene Define the scene the texture belongs to
  12374. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12375. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12376. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12377. * @returns the luminance alpha texture
  12378. */
  12379. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12380. /**
  12381. * Creates an alpha texture from some data.
  12382. * @param data Define the texture data
  12383. * @param width Define the width of the texture
  12384. * @param height Define the height of the texture
  12385. * @param scene Define the scene the texture belongs to
  12386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12389. * @returns the alpha texture
  12390. */
  12391. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12392. /**
  12393. * Creates a RGB texture from some data.
  12394. * @param data Define the texture data
  12395. * @param width Define the width of the texture
  12396. * @param height Define the height of the texture
  12397. * @param scene Define the scene the texture belongs to
  12398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12401. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12402. * @returns the RGB alpha texture
  12403. */
  12404. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12405. /**
  12406. * Creates a RGBA texture from some data.
  12407. * @param data Define the texture data
  12408. * @param width Define the width of the texture
  12409. * @param height Define the height of the texture
  12410. * @param scene Define the scene the texture belongs to
  12411. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12415. * @returns the RGBA texture
  12416. */
  12417. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12418. /**
  12419. * Creates a R texture from some data.
  12420. * @param data Define the texture data
  12421. * @param width Define the width of the texture
  12422. * @param height Define the height of the texture
  12423. * @param scene Define the scene the texture belongs to
  12424. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12425. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12426. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12427. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12428. * @returns the R texture
  12429. */
  12430. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12431. }
  12432. }
  12433. declare module BABYLON {
  12434. /**
  12435. * Interface for the size containing width and height
  12436. */
  12437. export interface ISize {
  12438. /**
  12439. * Width
  12440. */
  12441. width: number;
  12442. /**
  12443. * Heighht
  12444. */
  12445. height: number;
  12446. }
  12447. /**
  12448. * Size containing widht and height
  12449. */
  12450. export class Size implements ISize {
  12451. /**
  12452. * Width
  12453. */
  12454. width: number;
  12455. /**
  12456. * Height
  12457. */
  12458. height: number;
  12459. /**
  12460. * Creates a Size object from the given width and height (floats).
  12461. * @param width width of the new size
  12462. * @param height height of the new size
  12463. */
  12464. constructor(width: number, height: number);
  12465. /**
  12466. * Returns a string with the Size width and height
  12467. * @returns a string with the Size width and height
  12468. */
  12469. toString(): string;
  12470. /**
  12471. * "Size"
  12472. * @returns the string "Size"
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Returns the Size hash code.
  12477. * @returns a hash code for a unique width and height
  12478. */
  12479. getHashCode(): number;
  12480. /**
  12481. * Updates the current size from the given one.
  12482. * @param src the given size
  12483. */
  12484. copyFrom(src: Size): void;
  12485. /**
  12486. * Updates in place the current Size from the given floats.
  12487. * @param width width of the new size
  12488. * @param height height of the new size
  12489. * @returns the updated Size.
  12490. */
  12491. copyFromFloats(width: number, height: number): Size;
  12492. /**
  12493. * Updates in place the current Size from the given floats.
  12494. * @param width width to set
  12495. * @param height height to set
  12496. * @returns the updated Size.
  12497. */
  12498. set(width: number, height: number): Size;
  12499. /**
  12500. * Multiplies the width and height by numbers
  12501. * @param w factor to multiple the width by
  12502. * @param h factor to multiple the height by
  12503. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12504. */
  12505. multiplyByFloats(w: number, h: number): Size;
  12506. /**
  12507. * Clones the size
  12508. * @returns a new Size copied from the given one.
  12509. */
  12510. clone(): Size;
  12511. /**
  12512. * True if the current Size and the given one width and height are strictly equal.
  12513. * @param other the other size to compare against
  12514. * @returns True if the current Size and the given one width and height are strictly equal.
  12515. */
  12516. equals(other: Size): boolean;
  12517. /**
  12518. * The surface of the Size : width * height (float).
  12519. */
  12520. readonly surface: number;
  12521. /**
  12522. * Create a new size of zero
  12523. * @returns a new Size set to (0.0, 0.0)
  12524. */
  12525. static Zero(): Size;
  12526. /**
  12527. * Sums the width and height of two sizes
  12528. * @param otherSize size to add to this size
  12529. * @returns a new Size set as the addition result of the current Size and the given one.
  12530. */
  12531. add(otherSize: Size): Size;
  12532. /**
  12533. * Subtracts the width and height of two
  12534. * @param otherSize size to subtract to this size
  12535. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12536. */
  12537. subtract(otherSize: Size): Size;
  12538. /**
  12539. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12540. * @param start starting size to lerp between
  12541. * @param end end size to lerp between
  12542. * @param amount amount to lerp between the start and end values
  12543. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12544. */
  12545. static Lerp(start: Size, end: Size, amount: number): Size;
  12546. }
  12547. }
  12548. declare module BABYLON {
  12549. /**
  12550. * Defines a runtime animation
  12551. */
  12552. export class RuntimeAnimation {
  12553. private _events;
  12554. /**
  12555. * The current frame of the runtime animation
  12556. */
  12557. private _currentFrame;
  12558. /**
  12559. * The animation used by the runtime animation
  12560. */
  12561. private _animation;
  12562. /**
  12563. * The target of the runtime animation
  12564. */
  12565. private _target;
  12566. /**
  12567. * The initiating animatable
  12568. */
  12569. private _host;
  12570. /**
  12571. * The original value of the runtime animation
  12572. */
  12573. private _originalValue;
  12574. /**
  12575. * The original blend value of the runtime animation
  12576. */
  12577. private _originalBlendValue;
  12578. /**
  12579. * The offsets cache of the runtime animation
  12580. */
  12581. private _offsetsCache;
  12582. /**
  12583. * The high limits cache of the runtime animation
  12584. */
  12585. private _highLimitsCache;
  12586. /**
  12587. * Specifies if the runtime animation has been stopped
  12588. */
  12589. private _stopped;
  12590. /**
  12591. * The blending factor of the runtime animation
  12592. */
  12593. private _blendingFactor;
  12594. /**
  12595. * The BabylonJS scene
  12596. */
  12597. private _scene;
  12598. /**
  12599. * The current value of the runtime animation
  12600. */
  12601. private _currentValue;
  12602. /** @hidden */
  12603. _animationState: _IAnimationState;
  12604. /**
  12605. * The active target of the runtime animation
  12606. */
  12607. private _activeTargets;
  12608. private _currentActiveTarget;
  12609. private _directTarget;
  12610. /**
  12611. * The target path of the runtime animation
  12612. */
  12613. private _targetPath;
  12614. /**
  12615. * The weight of the runtime animation
  12616. */
  12617. private _weight;
  12618. /**
  12619. * The ratio offset of the runtime animation
  12620. */
  12621. private _ratioOffset;
  12622. /**
  12623. * The previous delay of the runtime animation
  12624. */
  12625. private _previousDelay;
  12626. /**
  12627. * The previous ratio of the runtime animation
  12628. */
  12629. private _previousRatio;
  12630. private _enableBlending;
  12631. private _keys;
  12632. private _minFrame;
  12633. private _maxFrame;
  12634. private _minValue;
  12635. private _maxValue;
  12636. private _targetIsArray;
  12637. /**
  12638. * Gets the current frame of the runtime animation
  12639. */
  12640. readonly currentFrame: number;
  12641. /**
  12642. * Gets the weight of the runtime animation
  12643. */
  12644. readonly weight: number;
  12645. /**
  12646. * Gets the current value of the runtime animation
  12647. */
  12648. readonly currentValue: any;
  12649. /**
  12650. * Gets the target path of the runtime animation
  12651. */
  12652. readonly targetPath: string;
  12653. /**
  12654. * Gets the actual target of the runtime animation
  12655. */
  12656. readonly target: any;
  12657. /** @hidden */
  12658. _onLoop: () => void;
  12659. /**
  12660. * Create a new RuntimeAnimation object
  12661. * @param target defines the target of the animation
  12662. * @param animation defines the source animation object
  12663. * @param scene defines the hosting scene
  12664. * @param host defines the initiating Animatable
  12665. */
  12666. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12667. private _preparePath;
  12668. /**
  12669. * Gets the animation from the runtime animation
  12670. */
  12671. readonly animation: Animation;
  12672. /**
  12673. * Resets the runtime animation to the beginning
  12674. * @param restoreOriginal defines whether to restore the target property to the original value
  12675. */
  12676. reset(restoreOriginal?: boolean): void;
  12677. /**
  12678. * Specifies if the runtime animation is stopped
  12679. * @returns Boolean specifying if the runtime animation is stopped
  12680. */
  12681. isStopped(): boolean;
  12682. /**
  12683. * Disposes of the runtime animation
  12684. */
  12685. dispose(): void;
  12686. /**
  12687. * Apply the interpolated value to the target
  12688. * @param currentValue defines the value computed by the animation
  12689. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12690. */
  12691. setValue(currentValue: any, weight: number): void;
  12692. private _getOriginalValues;
  12693. private _setValue;
  12694. /**
  12695. * Gets the loop pmode of the runtime animation
  12696. * @returns Loop Mode
  12697. */
  12698. private _getCorrectLoopMode;
  12699. /**
  12700. * Move the current animation to a given frame
  12701. * @param frame defines the frame to move to
  12702. */
  12703. goToFrame(frame: number): void;
  12704. /**
  12705. * @hidden Internal use only
  12706. */
  12707. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12708. /**
  12709. * Execute the current animation
  12710. * @param delay defines the delay to add to the current frame
  12711. * @param from defines the lower bound of the animation range
  12712. * @param to defines the upper bound of the animation range
  12713. * @param loop defines if the current animation must loop
  12714. * @param speedRatio defines the current speed ratio
  12715. * @param weight defines the weight of the animation (default is -1 so no weight)
  12716. * @param onLoop optional callback called when animation loops
  12717. * @returns a boolean indicating if the animation is running
  12718. */
  12719. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12720. }
  12721. }
  12722. declare module BABYLON {
  12723. /**
  12724. * Class used to store an actual running animation
  12725. */
  12726. export class Animatable {
  12727. /** defines the target object */
  12728. target: any;
  12729. /** defines the starting frame number (default is 0) */
  12730. fromFrame: number;
  12731. /** defines the ending frame number (default is 100) */
  12732. toFrame: number;
  12733. /** defines if the animation must loop (default is false) */
  12734. loopAnimation: boolean;
  12735. /** defines a callback to call when animation ends if it is not looping */
  12736. onAnimationEnd?: (() => void) | null | undefined;
  12737. /** defines a callback to call when animation loops */
  12738. onAnimationLoop?: (() => void) | null | undefined;
  12739. private _localDelayOffset;
  12740. private _pausedDelay;
  12741. private _runtimeAnimations;
  12742. private _paused;
  12743. private _scene;
  12744. private _speedRatio;
  12745. private _weight;
  12746. private _syncRoot;
  12747. /**
  12748. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12749. * This will only apply for non looping animation (default is true)
  12750. */
  12751. disposeOnEnd: boolean;
  12752. /**
  12753. * Gets a boolean indicating if the animation has started
  12754. */
  12755. animationStarted: boolean;
  12756. /**
  12757. * Observer raised when the animation ends
  12758. */
  12759. onAnimationEndObservable: Observable<Animatable>;
  12760. /**
  12761. * Observer raised when the animation loops
  12762. */
  12763. onAnimationLoopObservable: Observable<Animatable>;
  12764. /**
  12765. * Gets the root Animatable used to synchronize and normalize animations
  12766. */
  12767. readonly syncRoot: Nullable<Animatable>;
  12768. /**
  12769. * Gets the current frame of the first RuntimeAnimation
  12770. * Used to synchronize Animatables
  12771. */
  12772. readonly masterFrame: number;
  12773. /**
  12774. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12775. */
  12776. weight: number;
  12777. /**
  12778. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12779. */
  12780. speedRatio: number;
  12781. /**
  12782. * Creates a new Animatable
  12783. * @param scene defines the hosting scene
  12784. * @param target defines the target object
  12785. * @param fromFrame defines the starting frame number (default is 0)
  12786. * @param toFrame defines the ending frame number (default is 100)
  12787. * @param loopAnimation defines if the animation must loop (default is false)
  12788. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12789. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12790. * @param animations defines a group of animation to add to the new Animatable
  12791. * @param onAnimationLoop defines a callback to call when animation loops
  12792. */
  12793. constructor(scene: Scene,
  12794. /** defines the target object */
  12795. target: any,
  12796. /** defines the starting frame number (default is 0) */
  12797. fromFrame?: number,
  12798. /** defines the ending frame number (default is 100) */
  12799. toFrame?: number,
  12800. /** defines if the animation must loop (default is false) */
  12801. loopAnimation?: boolean, speedRatio?: number,
  12802. /** defines a callback to call when animation ends if it is not looping */
  12803. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12804. /** defines a callback to call when animation loops */
  12805. onAnimationLoop?: (() => void) | null | undefined);
  12806. /**
  12807. * Synchronize and normalize current Animatable with a source Animatable
  12808. * This is useful when using animation weights and when animations are not of the same length
  12809. * @param root defines the root Animatable to synchronize with
  12810. * @returns the current Animatable
  12811. */
  12812. syncWith(root: Animatable): Animatable;
  12813. /**
  12814. * Gets the list of runtime animations
  12815. * @returns an array of RuntimeAnimation
  12816. */
  12817. getAnimations(): RuntimeAnimation[];
  12818. /**
  12819. * Adds more animations to the current animatable
  12820. * @param target defines the target of the animations
  12821. * @param animations defines the new animations to add
  12822. */
  12823. appendAnimations(target: any, animations: Animation[]): void;
  12824. /**
  12825. * Gets the source animation for a specific property
  12826. * @param property defines the propertyu to look for
  12827. * @returns null or the source animation for the given property
  12828. */
  12829. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12830. /**
  12831. * Gets the runtime animation for a specific property
  12832. * @param property defines the propertyu to look for
  12833. * @returns null or the runtime animation for the given property
  12834. */
  12835. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12836. /**
  12837. * Resets the animatable to its original state
  12838. */
  12839. reset(): void;
  12840. /**
  12841. * Allows the animatable to blend with current running animations
  12842. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12843. * @param blendingSpeed defines the blending speed to use
  12844. */
  12845. enableBlending(blendingSpeed: number): void;
  12846. /**
  12847. * Disable animation blending
  12848. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12849. */
  12850. disableBlending(): void;
  12851. /**
  12852. * Jump directly to a given frame
  12853. * @param frame defines the frame to jump to
  12854. */
  12855. goToFrame(frame: number): void;
  12856. /**
  12857. * Pause the animation
  12858. */
  12859. pause(): void;
  12860. /**
  12861. * Restart the animation
  12862. */
  12863. restart(): void;
  12864. private _raiseOnAnimationEnd;
  12865. /**
  12866. * Stop and delete the current animation
  12867. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12868. * @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)
  12869. */
  12870. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12871. /**
  12872. * Wait asynchronously for the animation to end
  12873. * @returns a promise which will be fullfilled when the animation ends
  12874. */
  12875. waitAsync(): Promise<Animatable>;
  12876. /** @hidden */
  12877. _animate(delay: number): boolean;
  12878. }
  12879. interface Scene {
  12880. /** @hidden */
  12881. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12882. /** @hidden */
  12883. _processLateAnimationBindingsForMatrices(holder: {
  12884. totalWeight: number;
  12885. animations: RuntimeAnimation[];
  12886. originalValue: Matrix;
  12887. }): any;
  12888. /** @hidden */
  12889. _processLateAnimationBindingsForQuaternions(holder: {
  12890. totalWeight: number;
  12891. animations: RuntimeAnimation[];
  12892. originalValue: Quaternion;
  12893. }, refQuaternion: Quaternion): Quaternion;
  12894. /** @hidden */
  12895. _processLateAnimationBindings(): void;
  12896. /**
  12897. * Will start the animation sequence of a given target
  12898. * @param target defines the target
  12899. * @param from defines from which frame should animation start
  12900. * @param to defines until which frame should animation run.
  12901. * @param weight defines the weight to apply to the animation (1.0 by default)
  12902. * @param loop defines if the animation loops
  12903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12904. * @param onAnimationEnd defines the function to be executed when the animation ends
  12905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12906. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12907. * @param onAnimationLoop defines the callback to call when an animation loops
  12908. * @returns the animatable object created for this animation
  12909. */
  12910. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12911. /**
  12912. * Will start the animation sequence of a given target
  12913. * @param target defines the target
  12914. * @param from defines from which frame should animation start
  12915. * @param to defines until which frame should animation run.
  12916. * @param loop defines if the animation loops
  12917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12918. * @param onAnimationEnd defines the function to be executed when the animation ends
  12919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12920. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12921. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12922. * @param onAnimationLoop defines the callback to call when an animation loops
  12923. * @returns the animatable object created for this animation
  12924. */
  12925. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12926. /**
  12927. * Will start the animation sequence of a given target and its hierarchy
  12928. * @param target defines the target
  12929. * @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.
  12930. * @param from defines from which frame should animation start
  12931. * @param to defines until which frame should animation run.
  12932. * @param loop defines if the animation loops
  12933. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12934. * @param onAnimationEnd defines the function to be executed when the animation ends
  12935. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12936. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12938. * @param onAnimationLoop defines the callback to call when an animation loops
  12939. * @returns the list of created animatables
  12940. */
  12941. 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[];
  12942. /**
  12943. * Begin a new animation on a given node
  12944. * @param target defines the target where the animation will take place
  12945. * @param animations defines the list of animations to start
  12946. * @param from defines the initial value
  12947. * @param to defines the final value
  12948. * @param loop defines if you want animation to loop (off by default)
  12949. * @param speedRatio defines the speed ratio to apply to all animations
  12950. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12951. * @param onAnimationLoop defines the callback to call when an animation loops
  12952. * @returns the list of created animatables
  12953. */
  12954. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12955. /**
  12956. * Begin a new animation on a given node and its hierarchy
  12957. * @param target defines the root node where the animation will take place
  12958. * @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.
  12959. * @param animations defines the list of animations to start
  12960. * @param from defines the initial value
  12961. * @param to defines the final value
  12962. * @param loop defines if you want animation to loop (off by default)
  12963. * @param speedRatio defines the speed ratio to apply to all animations
  12964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12965. * @param onAnimationLoop defines the callback to call when an animation loops
  12966. * @returns the list of animatables created for all nodes
  12967. */
  12968. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12969. /**
  12970. * Gets the animatable associated with a specific target
  12971. * @param target defines the target of the animatable
  12972. * @returns the required animatable if found
  12973. */
  12974. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12975. /**
  12976. * Gets all animatables associated with a given target
  12977. * @param target defines the target to look animatables for
  12978. * @returns an array of Animatables
  12979. */
  12980. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12981. /**
  12982. * Stops and removes all animations that have been applied to the scene
  12983. */
  12984. stopAllAnimations(): void;
  12985. }
  12986. interface Bone {
  12987. /**
  12988. * Copy an animation range from another bone
  12989. * @param source defines the source bone
  12990. * @param rangeName defines the range name to copy
  12991. * @param frameOffset defines the frame offset
  12992. * @param rescaleAsRequired defines if rescaling must be applied if required
  12993. * @param skelDimensionsRatio defines the scaling ratio
  12994. * @returns true if operation was successful
  12995. */
  12996. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * Class used to override all child animations of a given target
  13002. */
  13003. export class AnimationPropertiesOverride {
  13004. /**
  13005. * Gets or sets a value indicating if animation blending must be used
  13006. */
  13007. enableBlending: boolean;
  13008. /**
  13009. * Gets or sets the blending speed to use when enableBlending is true
  13010. */
  13011. blendingSpeed: number;
  13012. /**
  13013. * Gets or sets the default loop mode to use
  13014. */
  13015. loopMode: number;
  13016. }
  13017. }
  13018. declare module BABYLON {
  13019. /**
  13020. * Class used to handle skinning animations
  13021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13022. */
  13023. export class Skeleton implements IAnimatable {
  13024. /** defines the skeleton name */
  13025. name: string;
  13026. /** defines the skeleton Id */
  13027. id: string;
  13028. /**
  13029. * Defines the list of child bones
  13030. */
  13031. bones: Bone[];
  13032. /**
  13033. * Defines an estimate of the dimension of the skeleton at rest
  13034. */
  13035. dimensionsAtRest: Vector3;
  13036. /**
  13037. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13038. */
  13039. needInitialSkinMatrix: boolean;
  13040. /**
  13041. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13042. */
  13043. overrideMesh: Nullable<AbstractMesh>;
  13044. /**
  13045. * Gets the list of animations attached to this skeleton
  13046. */
  13047. animations: Array<Animation>;
  13048. private _scene;
  13049. private _isDirty;
  13050. private _transformMatrices;
  13051. private _transformMatrixTexture;
  13052. private _meshesWithPoseMatrix;
  13053. private _animatables;
  13054. private _identity;
  13055. private _synchronizedWithMesh;
  13056. private _ranges;
  13057. private _lastAbsoluteTransformsUpdateId;
  13058. private _canUseTextureForBones;
  13059. private _uniqueId;
  13060. /** @hidden */
  13061. _numBonesWithLinkedTransformNode: number;
  13062. /** @hidden */
  13063. _hasWaitingData: Nullable<boolean>;
  13064. /**
  13065. * Specifies if the skeleton should be serialized
  13066. */
  13067. doNotSerialize: boolean;
  13068. private _useTextureToStoreBoneMatrices;
  13069. /**
  13070. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13071. * Please note that this option is not available if the hardware does not support it
  13072. */
  13073. useTextureToStoreBoneMatrices: boolean;
  13074. private _animationPropertiesOverride;
  13075. /**
  13076. * Gets or sets the animation properties override
  13077. */
  13078. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13079. /**
  13080. * List of inspectable custom properties (used by the Inspector)
  13081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13082. */
  13083. inspectableCustomProperties: IInspectable[];
  13084. /**
  13085. * An observable triggered before computing the skeleton's matrices
  13086. */
  13087. onBeforeComputeObservable: Observable<Skeleton>;
  13088. /**
  13089. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13090. */
  13091. readonly isUsingTextureForMatrices: boolean;
  13092. /**
  13093. * Gets the unique ID of this skeleton
  13094. */
  13095. readonly uniqueId: number;
  13096. /**
  13097. * Creates a new skeleton
  13098. * @param name defines the skeleton name
  13099. * @param id defines the skeleton Id
  13100. * @param scene defines the hosting scene
  13101. */
  13102. constructor(
  13103. /** defines the skeleton name */
  13104. name: string,
  13105. /** defines the skeleton Id */
  13106. id: string, scene: Scene);
  13107. /**
  13108. * Gets the current object class name.
  13109. * @return the class name
  13110. */
  13111. getClassName(): string;
  13112. /**
  13113. * Returns an array containing the root bones
  13114. * @returns an array containing the root bones
  13115. */
  13116. getChildren(): Array<Bone>;
  13117. /**
  13118. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13120. * @returns a Float32Array containing matrices data
  13121. */
  13122. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13123. /**
  13124. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13125. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13126. * @returns a raw texture containing the data
  13127. */
  13128. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13129. /**
  13130. * Gets the current hosting scene
  13131. * @returns a scene object
  13132. */
  13133. getScene(): Scene;
  13134. /**
  13135. * Gets a string representing the current skeleton data
  13136. * @param fullDetails defines a boolean indicating if we want a verbose version
  13137. * @returns a string representing the current skeleton data
  13138. */
  13139. toString(fullDetails?: boolean): string;
  13140. /**
  13141. * Get bone's index searching by name
  13142. * @param name defines bone's name to search for
  13143. * @return the indice of the bone. Returns -1 if not found
  13144. */
  13145. getBoneIndexByName(name: string): number;
  13146. /**
  13147. * Creater a new animation range
  13148. * @param name defines the name of the range
  13149. * @param from defines the start key
  13150. * @param to defines the end key
  13151. */
  13152. createAnimationRange(name: string, from: number, to: number): void;
  13153. /**
  13154. * Delete a specific animation range
  13155. * @param name defines the name of the range
  13156. * @param deleteFrames defines if frames must be removed as well
  13157. */
  13158. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13159. /**
  13160. * Gets a specific animation range
  13161. * @param name defines the name of the range to look for
  13162. * @returns the requested animation range or null if not found
  13163. */
  13164. getAnimationRange(name: string): Nullable<AnimationRange>;
  13165. /**
  13166. * Gets the list of all animation ranges defined on this skeleton
  13167. * @returns an array
  13168. */
  13169. getAnimationRanges(): Nullable<AnimationRange>[];
  13170. /**
  13171. * Copy animation range from a source skeleton.
  13172. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13173. * @param source defines the source skeleton
  13174. * @param name defines the name of the range to copy
  13175. * @param rescaleAsRequired defines if rescaling must be applied if required
  13176. * @returns true if operation was successful
  13177. */
  13178. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13179. /**
  13180. * Forces the skeleton to go to rest pose
  13181. */
  13182. returnToRest(): void;
  13183. private _getHighestAnimationFrame;
  13184. /**
  13185. * Begin a specific animation range
  13186. * @param name defines the name of the range to start
  13187. * @param loop defines if looping must be turned on (false by default)
  13188. * @param speedRatio defines the speed ratio to apply (1 by default)
  13189. * @param onAnimationEnd defines a callback which will be called when animation will end
  13190. * @returns a new animatable
  13191. */
  13192. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13193. /** @hidden */
  13194. _markAsDirty(): void;
  13195. /** @hidden */
  13196. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13197. /** @hidden */
  13198. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13199. private _computeTransformMatrices;
  13200. /**
  13201. * Build all resources required to render a skeleton
  13202. */
  13203. prepare(): void;
  13204. /**
  13205. * Gets the list of animatables currently running for this skeleton
  13206. * @returns an array of animatables
  13207. */
  13208. getAnimatables(): IAnimatable[];
  13209. /**
  13210. * Clone the current skeleton
  13211. * @param name defines the name of the new skeleton
  13212. * @param id defines the id of the new skeleton
  13213. * @returns the new skeleton
  13214. */
  13215. clone(name: string, id: string): Skeleton;
  13216. /**
  13217. * Enable animation blending for this skeleton
  13218. * @param blendingSpeed defines the blending speed to apply
  13219. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13220. */
  13221. enableBlending(blendingSpeed?: number): void;
  13222. /**
  13223. * Releases all resources associated with the current skeleton
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Serialize the skeleton in a JSON object
  13228. * @returns a JSON object
  13229. */
  13230. serialize(): any;
  13231. /**
  13232. * Creates a new skeleton from serialized data
  13233. * @param parsedSkeleton defines the serialized data
  13234. * @param scene defines the hosting scene
  13235. * @returns a new skeleton
  13236. */
  13237. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13238. /**
  13239. * Compute all node absolute transforms
  13240. * @param forceUpdate defines if computation must be done even if cache is up to date
  13241. */
  13242. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13243. /**
  13244. * Gets the root pose matrix
  13245. * @returns a matrix
  13246. */
  13247. getPoseMatrix(): Nullable<Matrix>;
  13248. /**
  13249. * Sorts bones per internal index
  13250. */
  13251. sortBones(): void;
  13252. private _sortBones;
  13253. }
  13254. }
  13255. declare module BABYLON {
  13256. /**
  13257. * Class used to store bone information
  13258. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13259. */
  13260. export class Bone extends Node {
  13261. /**
  13262. * defines the bone name
  13263. */
  13264. name: string;
  13265. private static _tmpVecs;
  13266. private static _tmpQuat;
  13267. private static _tmpMats;
  13268. /**
  13269. * Gets the list of child bones
  13270. */
  13271. children: Bone[];
  13272. /** Gets the animations associated with this bone */
  13273. animations: Animation[];
  13274. /**
  13275. * Gets or sets bone length
  13276. */
  13277. length: number;
  13278. /**
  13279. * @hidden Internal only
  13280. * Set this value to map this bone to a different index in the transform matrices
  13281. * Set this value to -1 to exclude the bone from the transform matrices
  13282. */
  13283. _index: Nullable<number>;
  13284. private _skeleton;
  13285. private _localMatrix;
  13286. private _restPose;
  13287. private _baseMatrix;
  13288. private _absoluteTransform;
  13289. private _invertedAbsoluteTransform;
  13290. private _parent;
  13291. private _scalingDeterminant;
  13292. private _worldTransform;
  13293. private _localScaling;
  13294. private _localRotation;
  13295. private _localPosition;
  13296. private _needToDecompose;
  13297. private _needToCompose;
  13298. /** @hidden */
  13299. _linkedTransformNode: Nullable<TransformNode>;
  13300. /** @hidden */
  13301. _waitingTransformNodeId: Nullable<string>;
  13302. /** @hidden */
  13303. /** @hidden */
  13304. _matrix: Matrix;
  13305. /**
  13306. * Create a new bone
  13307. * @param name defines the bone name
  13308. * @param skeleton defines the parent skeleton
  13309. * @param parentBone defines the parent (can be null if the bone is the root)
  13310. * @param localMatrix defines the local matrix
  13311. * @param restPose defines the rest pose matrix
  13312. * @param baseMatrix defines the base matrix
  13313. * @param index defines index of the bone in the hiearchy
  13314. */
  13315. constructor(
  13316. /**
  13317. * defines the bone name
  13318. */
  13319. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13320. /**
  13321. * Gets the current object class name.
  13322. * @return the class name
  13323. */
  13324. getClassName(): string;
  13325. /**
  13326. * Gets the parent skeleton
  13327. * @returns a skeleton
  13328. */
  13329. getSkeleton(): Skeleton;
  13330. /**
  13331. * Gets parent bone
  13332. * @returns a bone or null if the bone is the root of the bone hierarchy
  13333. */
  13334. getParent(): Nullable<Bone>;
  13335. /**
  13336. * Returns an array containing the root bones
  13337. * @returns an array containing the root bones
  13338. */
  13339. getChildren(): Array<Bone>;
  13340. /**
  13341. * Sets the parent bone
  13342. * @param parent defines the parent (can be null if the bone is the root)
  13343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13344. */
  13345. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13346. /**
  13347. * Gets the local matrix
  13348. * @returns a matrix
  13349. */
  13350. getLocalMatrix(): Matrix;
  13351. /**
  13352. * Gets the base matrix (initial matrix which remains unchanged)
  13353. * @returns a matrix
  13354. */
  13355. getBaseMatrix(): Matrix;
  13356. /**
  13357. * Gets the rest pose matrix
  13358. * @returns a matrix
  13359. */
  13360. getRestPose(): Matrix;
  13361. /**
  13362. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13363. */
  13364. getWorldMatrix(): Matrix;
  13365. /**
  13366. * Sets the local matrix to rest pose matrix
  13367. */
  13368. returnToRest(): void;
  13369. /**
  13370. * Gets the inverse of the absolute transform matrix.
  13371. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13372. * @returns a matrix
  13373. */
  13374. getInvertedAbsoluteTransform(): Matrix;
  13375. /**
  13376. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13377. * @returns a matrix
  13378. */
  13379. getAbsoluteTransform(): Matrix;
  13380. /**
  13381. * Links with the given transform node.
  13382. * The local matrix of this bone is copied from the transform node every frame.
  13383. * @param transformNode defines the transform node to link to
  13384. */
  13385. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13386. /**
  13387. * Gets the node used to drive the bone's transformation
  13388. * @returns a transform node or null
  13389. */
  13390. getTransformNode(): Nullable<TransformNode>;
  13391. /** Gets or sets current position (in local space) */
  13392. position: Vector3;
  13393. /** Gets or sets current rotation (in local space) */
  13394. rotation: Vector3;
  13395. /** Gets or sets current rotation quaternion (in local space) */
  13396. rotationQuaternion: Quaternion;
  13397. /** Gets or sets current scaling (in local space) */
  13398. scaling: Vector3;
  13399. /**
  13400. * Gets the animation properties override
  13401. */
  13402. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13403. private _decompose;
  13404. private _compose;
  13405. /**
  13406. * Update the base and local matrices
  13407. * @param matrix defines the new base or local matrix
  13408. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13409. * @param updateLocalMatrix defines if the local matrix should be updated
  13410. */
  13411. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13412. /** @hidden */
  13413. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13414. /**
  13415. * Flag the bone as dirty (Forcing it to update everything)
  13416. */
  13417. markAsDirty(): void;
  13418. /** @hidden */
  13419. _markAsDirtyAndCompose(): void;
  13420. private _markAsDirtyAndDecompose;
  13421. /**
  13422. * Translate the bone in local or world space
  13423. * @param vec The amount to translate the bone
  13424. * @param space The space that the translation is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13428. /**
  13429. * Set the postion of the bone in local or world space
  13430. * @param position The position to set the bone
  13431. * @param space The space that the position is in
  13432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13433. */
  13434. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13435. /**
  13436. * Set the absolute position of the bone (world space)
  13437. * @param position The position to set the bone
  13438. * @param mesh The mesh that this bone is attached to
  13439. */
  13440. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13441. /**
  13442. * Scale the bone on the x, y and z axes (in local space)
  13443. * @param x The amount to scale the bone on the x axis
  13444. * @param y The amount to scale the bone on the y axis
  13445. * @param z The amount to scale the bone on the z axis
  13446. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13447. */
  13448. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13449. /**
  13450. * Set the bone scaling in local space
  13451. * @param scale defines the scaling vector
  13452. */
  13453. setScale(scale: Vector3): void;
  13454. /**
  13455. * Gets the current scaling in local space
  13456. * @returns the current scaling vector
  13457. */
  13458. getScale(): Vector3;
  13459. /**
  13460. * Gets the current scaling in local space and stores it in a target vector
  13461. * @param result defines the target vector
  13462. */
  13463. getScaleToRef(result: Vector3): void;
  13464. /**
  13465. * Set the yaw, pitch, and roll of the bone in local or world space
  13466. * @param yaw The rotation of the bone on the y axis
  13467. * @param pitch The rotation of the bone on the x axis
  13468. * @param roll The rotation of the bone on the z axis
  13469. * @param space The space that the axes of rotation are in
  13470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13471. */
  13472. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13473. /**
  13474. * Add a rotation to the bone on an axis in local or world space
  13475. * @param axis The axis to rotate the bone on
  13476. * @param amount The amount to rotate the bone
  13477. * @param space The space that the axis is in
  13478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13479. */
  13480. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13481. /**
  13482. * Set the rotation of the bone to a particular axis angle in local or world space
  13483. * @param axis The axis to rotate the bone on
  13484. * @param angle The angle that the bone should be rotated to
  13485. * @param space The space that the axis is in
  13486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13487. */
  13488. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13489. /**
  13490. * Set the euler rotation of the bone in local of world space
  13491. * @param rotation The euler rotation that the bone should be set to
  13492. * @param space The space that the rotation is in
  13493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13494. */
  13495. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13496. /**
  13497. * Set the quaternion rotation of the bone in local of world space
  13498. * @param quat The quaternion rotation that the bone should be set to
  13499. * @param space The space that the rotation is in
  13500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13501. */
  13502. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13503. /**
  13504. * Set the rotation matrix of the bone in local of world space
  13505. * @param rotMat The rotation matrix that the bone should be set to
  13506. * @param space The space that the rotation is in
  13507. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13508. */
  13509. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13510. private _rotateWithMatrix;
  13511. private _getNegativeRotationToRef;
  13512. /**
  13513. * Get the position of the bone in local or world space
  13514. * @param space The space that the returned position is in
  13515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13516. * @returns The position of the bone
  13517. */
  13518. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13519. /**
  13520. * Copy the position of the bone to a vector3 in local or world space
  13521. * @param space The space that the returned position is in
  13522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13523. * @param result The vector3 to copy the position to
  13524. */
  13525. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13526. /**
  13527. * Get the absolute position of the bone (world space)
  13528. * @param mesh The mesh that this bone is attached to
  13529. * @returns The absolute position of the bone
  13530. */
  13531. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13532. /**
  13533. * Copy the absolute position of the bone (world space) to the result param
  13534. * @param mesh The mesh that this bone is attached to
  13535. * @param result The vector3 to copy the absolute position to
  13536. */
  13537. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13538. /**
  13539. * Compute the absolute transforms of this bone and its children
  13540. */
  13541. computeAbsoluteTransforms(): void;
  13542. /**
  13543. * Get the world direction from an axis that is in the local space of the bone
  13544. * @param localAxis The local direction that is used to compute the world direction
  13545. * @param mesh The mesh that this bone is attached to
  13546. * @returns The world direction
  13547. */
  13548. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13549. /**
  13550. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13551. * @param localAxis The local direction that is used to compute the world direction
  13552. * @param mesh The mesh that this bone is attached to
  13553. * @param result The vector3 that the world direction will be copied to
  13554. */
  13555. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13556. /**
  13557. * Get the euler rotation of the bone in local or world space
  13558. * @param space The space that the rotation should be in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. * @returns The euler rotation
  13561. */
  13562. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13563. /**
  13564. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13565. * @param space The space that the rotation should be in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. * @param result The vector3 that the rotation should be copied to
  13568. */
  13569. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13570. /**
  13571. * Get the quaternion rotation of the bone in either local or world space
  13572. * @param space The space that the rotation should be in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. * @returns The quaternion rotation
  13575. */
  13576. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13577. /**
  13578. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13579. * @param space The space that the rotation should be in
  13580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13581. * @param result The quaternion that the rotation should be copied to
  13582. */
  13583. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13584. /**
  13585. * Get the rotation matrix of the bone in local or world space
  13586. * @param space The space that the rotation should be in
  13587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13588. * @returns The rotation matrix
  13589. */
  13590. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13591. /**
  13592. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13593. * @param space The space that the rotation should be in
  13594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13595. * @param result The quaternion that the rotation should be copied to
  13596. */
  13597. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13598. /**
  13599. * Get the world position of a point that is in the local space of the bone
  13600. * @param position The local position
  13601. * @param mesh The mesh that this bone is attached to
  13602. * @returns The world position
  13603. */
  13604. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13605. /**
  13606. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13607. * @param position The local position
  13608. * @param mesh The mesh that this bone is attached to
  13609. * @param result The vector3 that the world position should be copied to
  13610. */
  13611. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13612. /**
  13613. * Get the local position of a point that is in world space
  13614. * @param position The world position
  13615. * @param mesh The mesh that this bone is attached to
  13616. * @returns The local position
  13617. */
  13618. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13619. /**
  13620. * Get the local position of a point that is in world space and copy it to the result param
  13621. * @param position The world position
  13622. * @param mesh The mesh that this bone is attached to
  13623. * @param result The vector3 that the local position should be copied to
  13624. */
  13625. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /**
  13630. * 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.
  13631. * @see https://doc.babylonjs.com/how_to/transformnode
  13632. */
  13633. export class TransformNode extends Node {
  13634. /**
  13635. * Object will not rotate to face the camera
  13636. */
  13637. static BILLBOARDMODE_NONE: number;
  13638. /**
  13639. * Object will rotate to face the camera but only on the x axis
  13640. */
  13641. static BILLBOARDMODE_X: number;
  13642. /**
  13643. * Object will rotate to face the camera but only on the y axis
  13644. */
  13645. static BILLBOARDMODE_Y: number;
  13646. /**
  13647. * Object will rotate to face the camera but only on the z axis
  13648. */
  13649. static BILLBOARDMODE_Z: number;
  13650. /**
  13651. * Object will rotate to face the camera
  13652. */
  13653. static BILLBOARDMODE_ALL: number;
  13654. private _forward;
  13655. private _forwardInverted;
  13656. private _up;
  13657. private _right;
  13658. private _rightInverted;
  13659. private _position;
  13660. private _rotation;
  13661. private _rotationQuaternion;
  13662. protected _scaling: Vector3;
  13663. protected _isDirty: boolean;
  13664. private _transformToBoneReferal;
  13665. private _isAbsoluteSynced;
  13666. private _billboardMode;
  13667. /**
  13668. * Gets or sets the billboard mode. Default is 0.
  13669. *
  13670. * | Value | Type | Description |
  13671. * | --- | --- | --- |
  13672. * | 0 | BILLBOARDMODE_NONE | |
  13673. * | 1 | BILLBOARDMODE_X | |
  13674. * | 2 | BILLBOARDMODE_Y | |
  13675. * | 4 | BILLBOARDMODE_Z | |
  13676. * | 7 | BILLBOARDMODE_ALL | |
  13677. *
  13678. */
  13679. billboardMode: number;
  13680. private _preserveParentRotationForBillboard;
  13681. /**
  13682. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13683. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13684. */
  13685. preserveParentRotationForBillboard: boolean;
  13686. /**
  13687. * 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
  13688. */
  13689. scalingDeterminant: number;
  13690. private _infiniteDistance;
  13691. /**
  13692. * Gets or sets the distance of the object to max, often used by skybox
  13693. */
  13694. infiniteDistance: boolean;
  13695. /**
  13696. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13697. * By default the system will update normals to compensate
  13698. */
  13699. ignoreNonUniformScaling: boolean;
  13700. /**
  13701. * 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
  13702. */
  13703. reIntegrateRotationIntoRotationQuaternion: boolean;
  13704. /** @hidden */
  13705. _poseMatrix: Nullable<Matrix>;
  13706. /** @hidden */
  13707. _localMatrix: Matrix;
  13708. private _usePivotMatrix;
  13709. private _absolutePosition;
  13710. private _absoluteScaling;
  13711. private _absoluteRotationQuaternion;
  13712. private _pivotMatrix;
  13713. private _pivotMatrixInverse;
  13714. protected _postMultiplyPivotMatrix: boolean;
  13715. protected _isWorldMatrixFrozen: boolean;
  13716. /** @hidden */
  13717. _indexInSceneTransformNodesArray: number;
  13718. /**
  13719. * An event triggered after the world matrix is updated
  13720. */
  13721. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13722. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13723. /**
  13724. * Gets a string identifying the name of the class
  13725. * @returns "TransformNode" string
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13730. */
  13731. position: Vector3;
  13732. /**
  13733. * 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)).
  13734. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13735. */
  13736. rotation: Vector3;
  13737. /**
  13738. * 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)).
  13739. */
  13740. scaling: Vector3;
  13741. /**
  13742. * 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).
  13743. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13744. */
  13745. rotationQuaternion: Nullable<Quaternion>;
  13746. /**
  13747. * The forward direction of that transform in world space.
  13748. */
  13749. readonly forward: Vector3;
  13750. /**
  13751. * The up direction of that transform in world space.
  13752. */
  13753. readonly up: Vector3;
  13754. /**
  13755. * The right direction of that transform in world space.
  13756. */
  13757. readonly right: Vector3;
  13758. /**
  13759. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13760. * @param matrix the matrix to copy the pose from
  13761. * @returns this TransformNode.
  13762. */
  13763. updatePoseMatrix(matrix: Matrix): TransformNode;
  13764. /**
  13765. * Returns the mesh Pose matrix.
  13766. * @returns the pose matrix
  13767. */
  13768. getPoseMatrix(): Matrix;
  13769. /** @hidden */
  13770. _isSynchronized(): boolean;
  13771. /** @hidden */
  13772. _initCache(): void;
  13773. /**
  13774. * Flag the transform node as dirty (Forcing it to update everything)
  13775. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13776. * @returns this transform node
  13777. */
  13778. markAsDirty(property: string): TransformNode;
  13779. /**
  13780. * Returns the current mesh absolute position.
  13781. * Returns a Vector3.
  13782. */
  13783. readonly absolutePosition: Vector3;
  13784. /**
  13785. * Returns the current mesh absolute scaling.
  13786. * Returns a Vector3.
  13787. */
  13788. readonly absoluteScaling: Vector3;
  13789. /**
  13790. * Returns the current mesh absolute rotation.
  13791. * Returns a Quaternion.
  13792. */
  13793. readonly absoluteRotationQuaternion: Quaternion;
  13794. /**
  13795. * Sets a new matrix to apply before all other transformation
  13796. * @param matrix defines the transform matrix
  13797. * @returns the current TransformNode
  13798. */
  13799. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13800. /**
  13801. * Sets a new pivot matrix to the current node
  13802. * @param matrix defines the new pivot matrix to use
  13803. * @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
  13804. * @returns the current TransformNode
  13805. */
  13806. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13807. /**
  13808. * Returns the mesh pivot matrix.
  13809. * Default : Identity.
  13810. * @returns the matrix
  13811. */
  13812. getPivotMatrix(): Matrix;
  13813. /**
  13814. * Prevents the World matrix to be computed any longer.
  13815. * @returns the TransformNode.
  13816. */
  13817. freezeWorldMatrix(): TransformNode;
  13818. /**
  13819. * Allows back the World matrix computation.
  13820. * @returns the TransformNode.
  13821. */
  13822. unfreezeWorldMatrix(): this;
  13823. /**
  13824. * True if the World matrix has been frozen.
  13825. */
  13826. readonly isWorldMatrixFrozen: boolean;
  13827. /**
  13828. * Retuns the mesh absolute position in the World.
  13829. * @returns a Vector3.
  13830. */
  13831. getAbsolutePosition(): Vector3;
  13832. /**
  13833. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13834. * @param absolutePosition the absolute position to set
  13835. * @returns the TransformNode.
  13836. */
  13837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13838. /**
  13839. * Sets the mesh position in its local space.
  13840. * @param vector3 the position to set in localspace
  13841. * @returns the TransformNode.
  13842. */
  13843. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13844. /**
  13845. * Returns the mesh position in the local space from the current World matrix values.
  13846. * @returns a new Vector3.
  13847. */
  13848. getPositionExpressedInLocalSpace(): Vector3;
  13849. /**
  13850. * Translates the mesh along the passed Vector3 in its local space.
  13851. * @param vector3 the distance to translate in localspace
  13852. * @returns the TransformNode.
  13853. */
  13854. locallyTranslate(vector3: Vector3): TransformNode;
  13855. private static _lookAtVectorCache;
  13856. /**
  13857. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13858. * @param targetPoint the position (must be in same space as current mesh) to look at
  13859. * @param yawCor optional yaw (y-axis) correction in radians
  13860. * @param pitchCor optional pitch (x-axis) correction in radians
  13861. * @param rollCor optional roll (z-axis) correction in radians
  13862. * @param space the choosen space of the target
  13863. * @returns the TransformNode.
  13864. */
  13865. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13866. /**
  13867. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13868. * This Vector3 is expressed in the World space.
  13869. * @param localAxis axis to rotate
  13870. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13871. */
  13872. getDirection(localAxis: Vector3): Vector3;
  13873. /**
  13874. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13875. * localAxis is expressed in the mesh local space.
  13876. * result is computed in the Wordl space from the mesh World matrix.
  13877. * @param localAxis axis to rotate
  13878. * @param result the resulting transformnode
  13879. * @returns this TransformNode.
  13880. */
  13881. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13882. /**
  13883. * Sets this transform node rotation to the given local axis.
  13884. * @param localAxis the axis in local space
  13885. * @param yawCor optional yaw (y-axis) correction in radians
  13886. * @param pitchCor optional pitch (x-axis) correction in radians
  13887. * @param rollCor optional roll (z-axis) correction in radians
  13888. * @returns this TransformNode
  13889. */
  13890. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13891. /**
  13892. * Sets a new pivot point to the current node
  13893. * @param point defines the new pivot point to use
  13894. * @param space defines if the point is in world or local space (local by default)
  13895. * @returns the current TransformNode
  13896. */
  13897. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13898. /**
  13899. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13900. * @returns the pivot point
  13901. */
  13902. getPivotPoint(): Vector3;
  13903. /**
  13904. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13905. * @param result the vector3 to store the result
  13906. * @returns this TransformNode.
  13907. */
  13908. getPivotPointToRef(result: Vector3): TransformNode;
  13909. /**
  13910. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13911. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13912. */
  13913. getAbsolutePivotPoint(): Vector3;
  13914. /**
  13915. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13916. * @param result vector3 to store the result
  13917. * @returns this TransformNode.
  13918. */
  13919. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13920. /**
  13921. * Defines the passed node as the parent of the current node.
  13922. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13923. * @see https://doc.babylonjs.com/how_to/parenting
  13924. * @param node the node ot set as the parent
  13925. * @returns this TransformNode.
  13926. */
  13927. setParent(node: Nullable<Node>): TransformNode;
  13928. private _nonUniformScaling;
  13929. /**
  13930. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13931. */
  13932. readonly nonUniformScaling: boolean;
  13933. /** @hidden */
  13934. _updateNonUniformScalingState(value: boolean): boolean;
  13935. /**
  13936. * Attach the current TransformNode to another TransformNode associated with a bone
  13937. * @param bone Bone affecting the TransformNode
  13938. * @param affectedTransformNode TransformNode associated with the bone
  13939. * @returns this object
  13940. */
  13941. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13942. /**
  13943. * Detach the transform node if its associated with a bone
  13944. * @returns this object
  13945. */
  13946. detachFromBone(): TransformNode;
  13947. private static _rotationAxisCache;
  13948. /**
  13949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13952. * The passed axis is also normalized.
  13953. * @param axis the axis to rotate around
  13954. * @param amount the amount to rotate in radians
  13955. * @param space Space to rotate in (Default: local)
  13956. * @returns the TransformNode.
  13957. */
  13958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13959. /**
  13960. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13962. * The passed axis is also normalized. .
  13963. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13964. * @param point the point to rotate around
  13965. * @param axis the axis to rotate around
  13966. * @param amount the amount to rotate in radians
  13967. * @returns the TransformNode
  13968. */
  13969. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13970. /**
  13971. * Translates the mesh along the axis vector for the passed distance in the given space.
  13972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13973. * @param axis the axis to translate in
  13974. * @param distance the distance to translate
  13975. * @param space Space to rotate in (Default: local)
  13976. * @returns the TransformNode.
  13977. */
  13978. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13979. /**
  13980. * Adds a rotation step to the mesh current rotation.
  13981. * x, y, z are Euler angles expressed in radians.
  13982. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13983. * This means this rotation is made in the mesh local space only.
  13984. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13985. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13986. * ```javascript
  13987. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13988. * ```
  13989. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13990. * 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.
  13991. * @param x Rotation to add
  13992. * @param y Rotation to add
  13993. * @param z Rotation to add
  13994. * @returns the TransformNode.
  13995. */
  13996. addRotation(x: number, y: number, z: number): TransformNode;
  13997. /**
  13998. * @hidden
  13999. */
  14000. protected _getEffectiveParent(): Nullable<Node>;
  14001. /**
  14002. * Computes the world matrix of the node
  14003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14004. * @returns the world matrix
  14005. */
  14006. computeWorldMatrix(force?: boolean): Matrix;
  14007. protected _afterComputeWorldMatrix(): void;
  14008. /**
  14009. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14010. * @param func callback function to add
  14011. *
  14012. * @returns the TransformNode.
  14013. */
  14014. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14015. /**
  14016. * Removes a registered callback function.
  14017. * @param func callback function to remove
  14018. * @returns the TransformNode.
  14019. */
  14020. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14021. /**
  14022. * Gets the position of the current mesh in camera space
  14023. * @param camera defines the camera to use
  14024. * @returns a position
  14025. */
  14026. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14027. /**
  14028. * Returns the distance from the mesh to the active camera
  14029. * @param camera defines the camera to use
  14030. * @returns the distance
  14031. */
  14032. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14033. /**
  14034. * Clone the current transform node
  14035. * @param name Name of the new clone
  14036. * @param newParent New parent for the clone
  14037. * @param doNotCloneChildren Do not clone children hierarchy
  14038. * @returns the new transform node
  14039. */
  14040. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14041. /**
  14042. * Serializes the objects information.
  14043. * @param currentSerializationObject defines the object to serialize in
  14044. * @returns the serialized object
  14045. */
  14046. serialize(currentSerializationObject?: any): any;
  14047. /**
  14048. * Returns a new TransformNode object parsed from the source provided.
  14049. * @param parsedTransformNode is the source.
  14050. * @param scene the scne the object belongs to
  14051. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14052. * @returns a new TransformNode object parsed from the source provided.
  14053. */
  14054. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14055. /**
  14056. * Get all child-transformNodes of this node
  14057. * @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
  14058. * @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
  14059. * @returns an array of TransformNode
  14060. */
  14061. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14062. /**
  14063. * Releases resources associated with this transform node.
  14064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14066. */
  14067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14068. /**
  14069. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14070. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14071. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14072. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14073. * @returns the current mesh
  14074. */
  14075. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14076. private _syncAbsoluteScalingAndRotation;
  14077. }
  14078. }
  14079. declare module BABYLON {
  14080. /**
  14081. * Defines the types of pose enabled controllers that are supported
  14082. */
  14083. export enum PoseEnabledControllerType {
  14084. /**
  14085. * HTC Vive
  14086. */
  14087. VIVE = 0,
  14088. /**
  14089. * Oculus Rift
  14090. */
  14091. OCULUS = 1,
  14092. /**
  14093. * Windows mixed reality
  14094. */
  14095. WINDOWS = 2,
  14096. /**
  14097. * Samsung gear VR
  14098. */
  14099. GEAR_VR = 3,
  14100. /**
  14101. * Google Daydream
  14102. */
  14103. DAYDREAM = 4,
  14104. /**
  14105. * Generic
  14106. */
  14107. GENERIC = 5
  14108. }
  14109. /**
  14110. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14111. */
  14112. export interface MutableGamepadButton {
  14113. /**
  14114. * Value of the button/trigger
  14115. */
  14116. value: number;
  14117. /**
  14118. * If the button/trigger is currently touched
  14119. */
  14120. touched: boolean;
  14121. /**
  14122. * If the button/trigger is currently pressed
  14123. */
  14124. pressed: boolean;
  14125. }
  14126. /**
  14127. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14128. * @hidden
  14129. */
  14130. export interface ExtendedGamepadButton extends GamepadButton {
  14131. /**
  14132. * If the button/trigger is currently pressed
  14133. */
  14134. readonly pressed: boolean;
  14135. /**
  14136. * If the button/trigger is currently touched
  14137. */
  14138. readonly touched: boolean;
  14139. /**
  14140. * Value of the button/trigger
  14141. */
  14142. readonly value: number;
  14143. }
  14144. /** @hidden */
  14145. export interface _GamePadFactory {
  14146. /**
  14147. * Returns wether or not the current gamepad can be created for this type of controller.
  14148. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14149. * @returns true if it can be created, otherwise false
  14150. */
  14151. canCreate(gamepadInfo: any): boolean;
  14152. /**
  14153. * Creates a new instance of the Gamepad.
  14154. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14155. * @returns the new gamepad instance
  14156. */
  14157. create(gamepadInfo: any): Gamepad;
  14158. }
  14159. /**
  14160. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14161. */
  14162. export class PoseEnabledControllerHelper {
  14163. /** @hidden */
  14164. static _ControllerFactories: _GamePadFactory[];
  14165. /** @hidden */
  14166. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14167. /**
  14168. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14169. * @param vrGamepad the gamepad to initialized
  14170. * @returns a vr controller of the type the gamepad identified as
  14171. */
  14172. static InitiateController(vrGamepad: any): Gamepad;
  14173. }
  14174. /**
  14175. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14176. */
  14177. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14178. /**
  14179. * If the controller is used in a webXR session
  14180. */
  14181. isXR: boolean;
  14182. private _deviceRoomPosition;
  14183. private _deviceRoomRotationQuaternion;
  14184. /**
  14185. * The device position in babylon space
  14186. */
  14187. devicePosition: Vector3;
  14188. /**
  14189. * The device rotation in babylon space
  14190. */
  14191. deviceRotationQuaternion: Quaternion;
  14192. /**
  14193. * The scale factor of the device in babylon space
  14194. */
  14195. deviceScaleFactor: number;
  14196. /**
  14197. * (Likely devicePosition should be used instead) The device position in its room space
  14198. */
  14199. position: Vector3;
  14200. /**
  14201. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14202. */
  14203. rotationQuaternion: Quaternion;
  14204. /**
  14205. * The type of controller (Eg. Windows mixed reality)
  14206. */
  14207. controllerType: PoseEnabledControllerType;
  14208. protected _calculatedPosition: Vector3;
  14209. private _calculatedRotation;
  14210. /**
  14211. * The raw pose from the device
  14212. */
  14213. rawPose: DevicePose;
  14214. private _trackPosition;
  14215. private _maxRotationDistFromHeadset;
  14216. private _draggedRoomRotation;
  14217. /**
  14218. * @hidden
  14219. */
  14220. _disableTrackPosition(fixedPosition: Vector3): void;
  14221. /**
  14222. * Internal, the mesh attached to the controller
  14223. * @hidden
  14224. */
  14225. _mesh: Nullable<AbstractMesh>;
  14226. private _poseControlledCamera;
  14227. private _leftHandSystemQuaternion;
  14228. /**
  14229. * Internal, matrix used to convert room space to babylon space
  14230. * @hidden
  14231. */
  14232. _deviceToWorld: Matrix;
  14233. /**
  14234. * Node to be used when casting a ray from the controller
  14235. * @hidden
  14236. */
  14237. _pointingPoseNode: Nullable<TransformNode>;
  14238. /**
  14239. * Name of the child mesh that can be used to cast a ray from the controller
  14240. */
  14241. static readonly POINTING_POSE: string;
  14242. /**
  14243. * Creates a new PoseEnabledController from a gamepad
  14244. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14245. */
  14246. constructor(browserGamepad: any);
  14247. private _workingMatrix;
  14248. /**
  14249. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14250. */
  14251. update(): void;
  14252. /**
  14253. * Updates only the pose device and mesh without doing any button event checking
  14254. */
  14255. protected _updatePoseAndMesh(): void;
  14256. /**
  14257. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14258. * @param poseData raw pose fromthe device
  14259. */
  14260. updateFromDevice(poseData: DevicePose): void;
  14261. /**
  14262. * @hidden
  14263. */
  14264. _meshAttachedObservable: Observable<AbstractMesh>;
  14265. /**
  14266. * Attaches a mesh to the controller
  14267. * @param mesh the mesh to be attached
  14268. */
  14269. attachToMesh(mesh: AbstractMesh): void;
  14270. /**
  14271. * Attaches the controllers mesh to a camera
  14272. * @param camera the camera the mesh should be attached to
  14273. */
  14274. attachToPoseControlledCamera(camera: TargetCamera): void;
  14275. /**
  14276. * Disposes of the controller
  14277. */
  14278. dispose(): void;
  14279. /**
  14280. * The mesh that is attached to the controller
  14281. */
  14282. readonly mesh: Nullable<AbstractMesh>;
  14283. /**
  14284. * Gets the ray of the controller in the direction the controller is pointing
  14285. * @param length the length the resulting ray should be
  14286. * @returns a ray in the direction the controller is pointing
  14287. */
  14288. getForwardRay(length?: number): Ray;
  14289. }
  14290. }
  14291. declare module BABYLON {
  14292. /**
  14293. * Defines the WebVRController object that represents controllers tracked in 3D space
  14294. */
  14295. export abstract class WebVRController extends PoseEnabledController {
  14296. /**
  14297. * Internal, the default controller model for the controller
  14298. */
  14299. protected _defaultModel: AbstractMesh;
  14300. /**
  14301. * Fired when the trigger state has changed
  14302. */
  14303. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14304. /**
  14305. * Fired when the main button state has changed
  14306. */
  14307. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14308. /**
  14309. * Fired when the secondary button state has changed
  14310. */
  14311. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14312. /**
  14313. * Fired when the pad state has changed
  14314. */
  14315. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14316. /**
  14317. * Fired when controllers stick values have changed
  14318. */
  14319. onPadValuesChangedObservable: Observable<StickValues>;
  14320. /**
  14321. * Array of button availible on the controller
  14322. */
  14323. protected _buttons: Array<MutableGamepadButton>;
  14324. private _onButtonStateChange;
  14325. /**
  14326. * Fired when a controller button's state has changed
  14327. * @param callback the callback containing the button that was modified
  14328. */
  14329. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14330. /**
  14331. * X and Y axis corresponding to the controllers joystick
  14332. */
  14333. pad: StickValues;
  14334. /**
  14335. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14336. */
  14337. hand: string;
  14338. /**
  14339. * The default controller model for the controller
  14340. */
  14341. readonly defaultModel: AbstractMesh;
  14342. /**
  14343. * Creates a new WebVRController from a gamepad
  14344. * @param vrGamepad the gamepad that the WebVRController should be created from
  14345. */
  14346. constructor(vrGamepad: any);
  14347. /**
  14348. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14349. */
  14350. update(): void;
  14351. /**
  14352. * Function to be called when a button is modified
  14353. */
  14354. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14355. /**
  14356. * Loads a mesh and attaches it to the controller
  14357. * @param scene the scene the mesh should be added to
  14358. * @param meshLoaded callback for when the mesh has been loaded
  14359. */
  14360. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14361. private _setButtonValue;
  14362. private _changes;
  14363. private _checkChanges;
  14364. /**
  14365. * Disposes of th webVRCOntroller
  14366. */
  14367. dispose(): void;
  14368. }
  14369. }
  14370. declare module BABYLON {
  14371. /**
  14372. * The HemisphericLight simulates the ambient environment light,
  14373. * so the passed direction is the light reflection direction, not the incoming direction.
  14374. */
  14375. export class HemisphericLight extends Light {
  14376. /**
  14377. * The groundColor is the light in the opposite direction to the one specified during creation.
  14378. * 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.
  14379. */
  14380. groundColor: Color3;
  14381. /**
  14382. * The light reflection direction, not the incoming direction.
  14383. */
  14384. direction: Vector3;
  14385. /**
  14386. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14387. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14388. * The HemisphericLight can't cast shadows.
  14389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14390. * @param name The friendly name of the light
  14391. * @param direction The direction of the light reflection
  14392. * @param scene The scene the light belongs to
  14393. */
  14394. constructor(name: string, direction: Vector3, scene: Scene);
  14395. protected _buildUniformLayout(): void;
  14396. /**
  14397. * Returns the string "HemisphericLight".
  14398. * @return The class name
  14399. */
  14400. getClassName(): string;
  14401. /**
  14402. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14403. * Returns the updated direction.
  14404. * @param target The target the direction should point to
  14405. * @return The computed direction
  14406. */
  14407. setDirectionToTarget(target: Vector3): Vector3;
  14408. /**
  14409. * Returns the shadow generator associated to the light.
  14410. * @returns Always null for hemispheric lights because it does not support shadows.
  14411. */
  14412. getShadowGenerator(): Nullable<IShadowGenerator>;
  14413. /**
  14414. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14415. * @param effect The effect to update
  14416. * @param lightIndex The index of the light in the effect to update
  14417. * @returns The hemispheric light
  14418. */
  14419. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14420. /**
  14421. * Computes the world matrix of the node
  14422. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14423. * @param useWasUpdatedFlag defines a reserved property
  14424. * @returns the world matrix
  14425. */
  14426. computeWorldMatrix(): Matrix;
  14427. /**
  14428. * Returns the integer 3.
  14429. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14430. */
  14431. getTypeID(): number;
  14432. /**
  14433. * Prepares the list of defines specific to the light type.
  14434. * @param defines the list of defines
  14435. * @param lightIndex defines the index of the light for the effect
  14436. */
  14437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14438. }
  14439. }
  14440. declare module BABYLON {
  14441. /** @hidden */
  14442. export var vrMultiviewToSingleviewPixelShader: {
  14443. name: string;
  14444. shader: string;
  14445. };
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * Renders to multiple views with a single draw call
  14450. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14451. */
  14452. export class MultiviewRenderTarget extends RenderTargetTexture {
  14453. /**
  14454. * Creates a multiview render target
  14455. * @param scene scene used with the render target
  14456. * @param size the size of the render target (used for each view)
  14457. */
  14458. constructor(scene: Scene, size?: number | {
  14459. width: number;
  14460. height: number;
  14461. } | {
  14462. ratio: number;
  14463. });
  14464. /**
  14465. * @hidden
  14466. * @param faceIndex the face index, if its a cube texture
  14467. */
  14468. _bindFrameBuffer(faceIndex?: number): void;
  14469. /**
  14470. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14471. * @returns the view count
  14472. */
  14473. getViewCount(): number;
  14474. }
  14475. }
  14476. declare module BABYLON {
  14477. /**
  14478. * Reprasents a camera frustum
  14479. */
  14480. export class Frustum {
  14481. /**
  14482. * Gets the planes representing the frustum
  14483. * @param transform matrix to be applied to the returned planes
  14484. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14485. */
  14486. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14487. /**
  14488. * Gets the near frustum plane transformed by the transform matrix
  14489. * @param transform transformation matrix to be applied to the resulting frustum plane
  14490. * @param frustumPlane the resuling frustum plane
  14491. */
  14492. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14493. /**
  14494. * Gets the far frustum plane transformed by the transform matrix
  14495. * @param transform transformation matrix to be applied to the resulting frustum plane
  14496. * @param frustumPlane the resuling frustum plane
  14497. */
  14498. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14499. /**
  14500. * Gets the left frustum plane transformed by the transform matrix
  14501. * @param transform transformation matrix to be applied to the resulting frustum plane
  14502. * @param frustumPlane the resuling frustum plane
  14503. */
  14504. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14505. /**
  14506. * Gets the right frustum plane transformed by the transform matrix
  14507. * @param transform transformation matrix to be applied to the resulting frustum plane
  14508. * @param frustumPlane the resuling frustum plane
  14509. */
  14510. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14511. /**
  14512. * Gets the top frustum plane transformed by the transform matrix
  14513. * @param transform transformation matrix to be applied to the resulting frustum plane
  14514. * @param frustumPlane the resuling frustum plane
  14515. */
  14516. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14517. /**
  14518. * Gets the bottom frustum plane transformed by the transform matrix
  14519. * @param transform transformation matrix to be applied to the resulting frustum plane
  14520. * @param frustumPlane the resuling frustum plane
  14521. */
  14522. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14523. /**
  14524. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14525. * @param transform transformation matrix to be applied to the resulting frustum planes
  14526. * @param frustumPlanes the resuling frustum planes
  14527. */
  14528. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14529. }
  14530. }
  14531. declare module BABYLON {
  14532. interface Engine {
  14533. /**
  14534. * Creates a new multiview render target
  14535. * @param width defines the width of the texture
  14536. * @param height defines the height of the texture
  14537. * @returns the created multiview texture
  14538. */
  14539. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14540. /**
  14541. * Binds a multiview framebuffer to be drawn to
  14542. * @param multiviewTexture texture to bind
  14543. */
  14544. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14545. }
  14546. interface Camera {
  14547. /**
  14548. * @hidden
  14549. * 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)
  14550. */
  14551. _useMultiviewToSingleView: boolean;
  14552. /**
  14553. * @hidden
  14554. * 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)
  14555. */
  14556. _multiviewTexture: Nullable<RenderTargetTexture>;
  14557. /**
  14558. * @hidden
  14559. * ensures the multiview texture of the camera exists and has the specified width/height
  14560. * @param width height to set on the multiview texture
  14561. * @param height width to set on the multiview texture
  14562. */
  14563. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14564. }
  14565. interface Scene {
  14566. /** @hidden */
  14567. _transformMatrixR: Matrix;
  14568. /** @hidden */
  14569. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14570. /** @hidden */
  14571. _createMultiviewUbo(): void;
  14572. /** @hidden */
  14573. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14574. /** @hidden */
  14575. _renderMultiviewToSingleView(camera: Camera): void;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14581. * This will not be used for webXR as it supports displaying texture arrays directly
  14582. */
  14583. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14584. /**
  14585. * Initializes a VRMultiviewToSingleview
  14586. * @param name name of the post process
  14587. * @param camera camera to be applied to
  14588. * @param scaleFactor scaling factor to the size of the output texture
  14589. */
  14590. constructor(name: string, camera: Camera, scaleFactor: number);
  14591. }
  14592. }
  14593. declare module BABYLON {
  14594. interface Engine {
  14595. /** @hidden */
  14596. _vrDisplay: any;
  14597. /** @hidden */
  14598. _vrSupported: boolean;
  14599. /** @hidden */
  14600. _oldSize: Size;
  14601. /** @hidden */
  14602. _oldHardwareScaleFactor: number;
  14603. /** @hidden */
  14604. _vrExclusivePointerMode: boolean;
  14605. /** @hidden */
  14606. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14607. /** @hidden */
  14608. _onVRDisplayPointerRestricted: () => void;
  14609. /** @hidden */
  14610. _onVRDisplayPointerUnrestricted: () => void;
  14611. /** @hidden */
  14612. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14613. /** @hidden */
  14614. _onVrDisplayDisconnect: Nullable<() => void>;
  14615. /** @hidden */
  14616. _onVrDisplayPresentChange: Nullable<() => void>;
  14617. /**
  14618. * Observable signaled when VR display mode changes
  14619. */
  14620. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14621. /**
  14622. * Observable signaled when VR request present is complete
  14623. */
  14624. onVRRequestPresentComplete: Observable<boolean>;
  14625. /**
  14626. * Observable signaled when VR request present starts
  14627. */
  14628. onVRRequestPresentStart: Observable<Engine>;
  14629. /**
  14630. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14631. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14632. */
  14633. isInVRExclusivePointerMode: boolean;
  14634. /**
  14635. * Gets a boolean indicating if a webVR device was detected
  14636. * @returns true if a webVR device was detected
  14637. */
  14638. isVRDevicePresent(): boolean;
  14639. /**
  14640. * Gets the current webVR device
  14641. * @returns the current webVR device (or null)
  14642. */
  14643. getVRDevice(): any;
  14644. /**
  14645. * Initializes a webVR display and starts listening to display change events
  14646. * The onVRDisplayChangedObservable will be notified upon these changes
  14647. * @returns A promise containing a VRDisplay and if vr is supported
  14648. */
  14649. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14650. /** @hidden */
  14651. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14652. /**
  14653. * Call this function to switch to webVR mode
  14654. * Will do nothing if webVR is not supported or if there is no webVR device
  14655. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14656. */
  14657. enableVR(): void;
  14658. /** @hidden */
  14659. _onVRFullScreenTriggered(): void;
  14660. }
  14661. }
  14662. declare module BABYLON {
  14663. /**
  14664. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14665. * IMPORTANT!! The data is right-hand data.
  14666. * @export
  14667. * @interface DevicePose
  14668. */
  14669. export interface DevicePose {
  14670. /**
  14671. * The position of the device, values in array are [x,y,z].
  14672. */
  14673. readonly position: Nullable<Float32Array>;
  14674. /**
  14675. * The linearVelocity of the device, values in array are [x,y,z].
  14676. */
  14677. readonly linearVelocity: Nullable<Float32Array>;
  14678. /**
  14679. * The linearAcceleration of the device, values in array are [x,y,z].
  14680. */
  14681. readonly linearAcceleration: Nullable<Float32Array>;
  14682. /**
  14683. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14684. */
  14685. readonly orientation: Nullable<Float32Array>;
  14686. /**
  14687. * The angularVelocity of the device, values in array are [x,y,z].
  14688. */
  14689. readonly angularVelocity: Nullable<Float32Array>;
  14690. /**
  14691. * The angularAcceleration of the device, values in array are [x,y,z].
  14692. */
  14693. readonly angularAcceleration: Nullable<Float32Array>;
  14694. }
  14695. /**
  14696. * Interface representing a pose controlled object in Babylon.
  14697. * A pose controlled object has both regular pose values as well as pose values
  14698. * from an external device such as a VR head mounted display
  14699. */
  14700. export interface PoseControlled {
  14701. /**
  14702. * The position of the object in babylon space.
  14703. */
  14704. position: Vector3;
  14705. /**
  14706. * The rotation quaternion of the object in babylon space.
  14707. */
  14708. rotationQuaternion: Quaternion;
  14709. /**
  14710. * The position of the device in babylon space.
  14711. */
  14712. devicePosition?: Vector3;
  14713. /**
  14714. * The rotation quaternion of the device in babylon space.
  14715. */
  14716. deviceRotationQuaternion: Quaternion;
  14717. /**
  14718. * The raw pose coming from the device.
  14719. */
  14720. rawPose: Nullable<DevicePose>;
  14721. /**
  14722. * The scale of the device to be used when translating from device space to babylon space.
  14723. */
  14724. deviceScaleFactor: number;
  14725. /**
  14726. * Updates the poseControlled values based on the input device pose.
  14727. * @param poseData the pose data to update the object with
  14728. */
  14729. updateFromDevice(poseData: DevicePose): void;
  14730. }
  14731. /**
  14732. * Set of options to customize the webVRCamera
  14733. */
  14734. export interface WebVROptions {
  14735. /**
  14736. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14737. */
  14738. trackPosition?: boolean;
  14739. /**
  14740. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14741. */
  14742. positionScale?: number;
  14743. /**
  14744. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14745. */
  14746. displayName?: string;
  14747. /**
  14748. * Should the native controller meshes be initialized. (default: true)
  14749. */
  14750. controllerMeshes?: boolean;
  14751. /**
  14752. * Creating a default HemiLight only on controllers. (default: true)
  14753. */
  14754. defaultLightingOnControllers?: boolean;
  14755. /**
  14756. * If you don't want to use the default VR button of the helper. (default: false)
  14757. */
  14758. useCustomVRButton?: boolean;
  14759. /**
  14760. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14761. */
  14762. customVRButton?: HTMLButtonElement;
  14763. /**
  14764. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14765. */
  14766. rayLength?: number;
  14767. /**
  14768. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14769. */
  14770. defaultHeight?: number;
  14771. /**
  14772. * If multiview should be used if availible (default: false)
  14773. */
  14774. useMultiview?: boolean;
  14775. }
  14776. /**
  14777. * This represents a WebVR camera.
  14778. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14779. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14780. */
  14781. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14782. private webVROptions;
  14783. /**
  14784. * @hidden
  14785. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14786. */
  14787. _vrDevice: any;
  14788. /**
  14789. * The rawPose of the vrDevice.
  14790. */
  14791. rawPose: Nullable<DevicePose>;
  14792. private _onVREnabled;
  14793. private _specsVersion;
  14794. private _attached;
  14795. private _frameData;
  14796. protected _descendants: Array<Node>;
  14797. private _deviceRoomPosition;
  14798. /** @hidden */
  14799. _deviceRoomRotationQuaternion: Quaternion;
  14800. private _standingMatrix;
  14801. /**
  14802. * Represents device position in babylon space.
  14803. */
  14804. devicePosition: Vector3;
  14805. /**
  14806. * Represents device rotation in babylon space.
  14807. */
  14808. deviceRotationQuaternion: Quaternion;
  14809. /**
  14810. * The scale of the device to be used when translating from device space to babylon space.
  14811. */
  14812. deviceScaleFactor: number;
  14813. private _deviceToWorld;
  14814. private _worldToDevice;
  14815. /**
  14816. * References to the webVR controllers for the vrDevice.
  14817. */
  14818. controllers: Array<WebVRController>;
  14819. /**
  14820. * Emits an event when a controller is attached.
  14821. */
  14822. onControllersAttachedObservable: Observable<WebVRController[]>;
  14823. /**
  14824. * Emits an event when a controller's mesh has been loaded;
  14825. */
  14826. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14827. /**
  14828. * Emits an event when the HMD's pose has been updated.
  14829. */
  14830. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14831. private _poseSet;
  14832. /**
  14833. * If the rig cameras be used as parent instead of this camera.
  14834. */
  14835. rigParenting: boolean;
  14836. private _lightOnControllers;
  14837. private _defaultHeight?;
  14838. /**
  14839. * Instantiates a WebVRFreeCamera.
  14840. * @param name The name of the WebVRFreeCamera
  14841. * @param position The starting anchor position for the camera
  14842. * @param scene The scene the camera belongs to
  14843. * @param webVROptions a set of customizable options for the webVRCamera
  14844. */
  14845. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14846. /**
  14847. * Gets the device distance from the ground in meters.
  14848. * @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.
  14849. */
  14850. deviceDistanceToRoomGround(): number;
  14851. /**
  14852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14853. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14854. */
  14855. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14856. /**
  14857. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14858. * @returns A promise with a boolean set to if the standing matrix is supported.
  14859. */
  14860. useStandingMatrixAsync(): Promise<boolean>;
  14861. /**
  14862. * Disposes the camera
  14863. */
  14864. dispose(): void;
  14865. /**
  14866. * Gets a vrController by name.
  14867. * @param name The name of the controller to retreive
  14868. * @returns the controller matching the name specified or null if not found
  14869. */
  14870. getControllerByName(name: string): Nullable<WebVRController>;
  14871. private _leftController;
  14872. /**
  14873. * The controller corresponding to the users left hand.
  14874. */
  14875. readonly leftController: Nullable<WebVRController>;
  14876. private _rightController;
  14877. /**
  14878. * The controller corresponding to the users right hand.
  14879. */
  14880. readonly rightController: Nullable<WebVRController>;
  14881. /**
  14882. * Casts a ray forward from the vrCamera's gaze.
  14883. * @param length Length of the ray (default: 100)
  14884. * @returns the ray corresponding to the gaze
  14885. */
  14886. getForwardRay(length?: number): Ray;
  14887. /**
  14888. * @hidden
  14889. * Updates the camera based on device's frame data
  14890. */
  14891. _checkInputs(): void;
  14892. /**
  14893. * Updates the poseControlled values based on the input device pose.
  14894. * @param poseData Pose coming from the device
  14895. */
  14896. updateFromDevice(poseData: DevicePose): void;
  14897. private _htmlElementAttached;
  14898. private _detachIfAttached;
  14899. /**
  14900. * WebVR's attach control will start broadcasting frames to the device.
  14901. * Note that in certain browsers (chrome for example) this function must be called
  14902. * within a user-interaction callback. Example:
  14903. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14904. *
  14905. * @param element html element to attach the vrDevice to
  14906. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14907. */
  14908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14909. /**
  14910. * Detaches the camera from the html element and disables VR
  14911. *
  14912. * @param element html element to detach from
  14913. */
  14914. detachControl(element: HTMLElement): void;
  14915. /**
  14916. * @returns the name of this class
  14917. */
  14918. getClassName(): string;
  14919. /**
  14920. * Calls resetPose on the vrDisplay
  14921. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14922. */
  14923. resetToCurrentRotation(): void;
  14924. /**
  14925. * @hidden
  14926. * Updates the rig cameras (left and right eye)
  14927. */
  14928. _updateRigCameras(): void;
  14929. private _workingVector;
  14930. private _oneVector;
  14931. private _workingMatrix;
  14932. private updateCacheCalled;
  14933. private _correctPositionIfNotTrackPosition;
  14934. /**
  14935. * @hidden
  14936. * Updates the cached values of the camera
  14937. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14938. */
  14939. _updateCache(ignoreParentClass?: boolean): void;
  14940. /**
  14941. * @hidden
  14942. * Get current device position in babylon world
  14943. */
  14944. _computeDevicePosition(): void;
  14945. /**
  14946. * Updates the current device position and rotation in the babylon world
  14947. */
  14948. update(): void;
  14949. /**
  14950. * @hidden
  14951. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14952. * @returns an identity matrix
  14953. */
  14954. _getViewMatrix(): Matrix;
  14955. private _tmpMatrix;
  14956. /**
  14957. * This function is called by the two RIG cameras.
  14958. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14959. * @hidden
  14960. */
  14961. _getWebVRViewMatrix(): Matrix;
  14962. /** @hidden */
  14963. _getWebVRProjectionMatrix(): Matrix;
  14964. private _onGamepadConnectedObserver;
  14965. private _onGamepadDisconnectedObserver;
  14966. private _updateCacheWhenTrackingDisabledObserver;
  14967. /**
  14968. * Initializes the controllers and their meshes
  14969. */
  14970. initControllers(): void;
  14971. }
  14972. }
  14973. declare module BABYLON {
  14974. /**
  14975. * Size options for a post process
  14976. */
  14977. export type PostProcessOptions = {
  14978. width: number;
  14979. height: number;
  14980. };
  14981. /**
  14982. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14983. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14984. */
  14985. export class PostProcess {
  14986. /** Name of the PostProcess. */
  14987. name: string;
  14988. /**
  14989. * Gets or sets the unique id of the post process
  14990. */
  14991. uniqueId: number;
  14992. /**
  14993. * Width of the texture to apply the post process on
  14994. */
  14995. width: number;
  14996. /**
  14997. * Height of the texture to apply the post process on
  14998. */
  14999. height: number;
  15000. /**
  15001. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15002. * @hidden
  15003. */
  15004. _outputTexture: Nullable<InternalTexture>;
  15005. /**
  15006. * Sampling mode used by the shader
  15007. * See https://doc.babylonjs.com/classes/3.1/texture
  15008. */
  15009. renderTargetSamplingMode: number;
  15010. /**
  15011. * Clear color to use when screen clearing
  15012. */
  15013. clearColor: Color4;
  15014. /**
  15015. * If the buffer needs to be cleared before applying the post process. (default: true)
  15016. * Should be set to false if shader will overwrite all previous pixels.
  15017. */
  15018. autoClear: boolean;
  15019. /**
  15020. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15021. */
  15022. alphaMode: number;
  15023. /**
  15024. * Sets the setAlphaBlendConstants of the babylon engine
  15025. */
  15026. alphaConstants: Color4;
  15027. /**
  15028. * Animations to be used for the post processing
  15029. */
  15030. animations: Animation[];
  15031. /**
  15032. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15033. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15034. */
  15035. enablePixelPerfectMode: boolean;
  15036. /**
  15037. * Force the postprocess to be applied without taking in account viewport
  15038. */
  15039. forceFullscreenViewport: boolean;
  15040. /**
  15041. * List of inspectable custom properties (used by the Inspector)
  15042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15043. */
  15044. inspectableCustomProperties: IInspectable[];
  15045. /**
  15046. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15047. *
  15048. * | Value | Type | Description |
  15049. * | ----- | ----------------------------------- | ----------- |
  15050. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15051. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15052. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15053. *
  15054. */
  15055. scaleMode: number;
  15056. /**
  15057. * Force textures to be a power of two (default: false)
  15058. */
  15059. alwaysForcePOT: boolean;
  15060. private _samples;
  15061. /**
  15062. * Number of sample textures (default: 1)
  15063. */
  15064. samples: number;
  15065. /**
  15066. * Modify the scale of the post process to be the same as the viewport (default: false)
  15067. */
  15068. adaptScaleToCurrentViewport: boolean;
  15069. private _camera;
  15070. private _scene;
  15071. private _engine;
  15072. private _options;
  15073. private _reusable;
  15074. private _textureType;
  15075. /**
  15076. * Smart array of input and output textures for the post process.
  15077. * @hidden
  15078. */
  15079. _textures: SmartArray<InternalTexture>;
  15080. /**
  15081. * The index in _textures that corresponds to the output texture.
  15082. * @hidden
  15083. */
  15084. _currentRenderTextureInd: number;
  15085. private _effect;
  15086. private _samplers;
  15087. private _fragmentUrl;
  15088. private _vertexUrl;
  15089. private _parameters;
  15090. private _scaleRatio;
  15091. protected _indexParameters: any;
  15092. private _shareOutputWithPostProcess;
  15093. private _texelSize;
  15094. private _forcedOutputTexture;
  15095. /**
  15096. * Returns the fragment url or shader name used in the post process.
  15097. * @returns the fragment url or name in the shader store.
  15098. */
  15099. getEffectName(): string;
  15100. /**
  15101. * An event triggered when the postprocess is activated.
  15102. */
  15103. onActivateObservable: Observable<Camera>;
  15104. private _onActivateObserver;
  15105. /**
  15106. * A function that is added to the onActivateObservable
  15107. */
  15108. onActivate: Nullable<(camera: Camera) => void>;
  15109. /**
  15110. * An event triggered when the postprocess changes its size.
  15111. */
  15112. onSizeChangedObservable: Observable<PostProcess>;
  15113. private _onSizeChangedObserver;
  15114. /**
  15115. * A function that is added to the onSizeChangedObservable
  15116. */
  15117. onSizeChanged: (postProcess: PostProcess) => void;
  15118. /**
  15119. * An event triggered when the postprocess applies its effect.
  15120. */
  15121. onApplyObservable: Observable<Effect>;
  15122. private _onApplyObserver;
  15123. /**
  15124. * A function that is added to the onApplyObservable
  15125. */
  15126. onApply: (effect: Effect) => void;
  15127. /**
  15128. * An event triggered before rendering the postprocess
  15129. */
  15130. onBeforeRenderObservable: Observable<Effect>;
  15131. private _onBeforeRenderObserver;
  15132. /**
  15133. * A function that is added to the onBeforeRenderObservable
  15134. */
  15135. onBeforeRender: (effect: Effect) => void;
  15136. /**
  15137. * An event triggered after rendering the postprocess
  15138. */
  15139. onAfterRenderObservable: Observable<Effect>;
  15140. private _onAfterRenderObserver;
  15141. /**
  15142. * A function that is added to the onAfterRenderObservable
  15143. */
  15144. onAfterRender: (efect: Effect) => void;
  15145. /**
  15146. * 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
  15147. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15148. */
  15149. inputTexture: InternalTexture;
  15150. /**
  15151. * Gets the camera which post process is applied to.
  15152. * @returns The camera the post process is applied to.
  15153. */
  15154. getCamera(): Camera;
  15155. /**
  15156. * Gets the texel size of the postprocess.
  15157. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15158. */
  15159. readonly texelSize: Vector2;
  15160. /**
  15161. * Creates a new instance PostProcess
  15162. * @param name The name of the PostProcess.
  15163. * @param fragmentUrl The url of the fragment shader to be used.
  15164. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15165. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15166. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15167. * @param camera The camera to apply the render pass to.
  15168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15169. * @param engine The engine which the post process will be applied. (default: current engine)
  15170. * @param reusable If the post process can be reused on the same frame. (default: false)
  15171. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15172. * @param textureType Type of textures used when performing the post process. (default: 0)
  15173. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15174. * @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
  15175. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15176. */
  15177. constructor(
  15178. /** Name of the PostProcess. */
  15179. 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);
  15180. /**
  15181. * Gets a string idenfifying the name of the class
  15182. * @returns "PostProcess" string
  15183. */
  15184. getClassName(): string;
  15185. /**
  15186. * Gets the engine which this post process belongs to.
  15187. * @returns The engine the post process was enabled with.
  15188. */
  15189. getEngine(): Engine;
  15190. /**
  15191. * The effect that is created when initializing the post process.
  15192. * @returns The created effect corresponding the the postprocess.
  15193. */
  15194. getEffect(): Effect;
  15195. /**
  15196. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15197. * @param postProcess The post process to share the output with.
  15198. * @returns This post process.
  15199. */
  15200. shareOutputWith(postProcess: PostProcess): PostProcess;
  15201. /**
  15202. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15203. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15204. */
  15205. useOwnOutput(): void;
  15206. /**
  15207. * Updates the effect with the current post process compile time values and recompiles the shader.
  15208. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15209. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15210. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15211. * @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
  15212. * @param onCompiled Called when the shader has been compiled.
  15213. * @param onError Called if there is an error when compiling a shader.
  15214. */
  15215. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15216. /**
  15217. * The post process is reusable if it can be used multiple times within one frame.
  15218. * @returns If the post process is reusable
  15219. */
  15220. isReusable(): boolean;
  15221. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15222. markTextureDirty(): void;
  15223. /**
  15224. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15225. * 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.
  15226. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15227. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15228. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15229. * @returns The target texture that was bound to be written to.
  15230. */
  15231. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15232. /**
  15233. * If the post process is supported.
  15234. */
  15235. readonly isSupported: boolean;
  15236. /**
  15237. * The aspect ratio of the output texture.
  15238. */
  15239. readonly aspectRatio: number;
  15240. /**
  15241. * Get a value indicating if the post-process is ready to be used
  15242. * @returns true if the post-process is ready (shader is compiled)
  15243. */
  15244. isReady(): boolean;
  15245. /**
  15246. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15247. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15248. */
  15249. apply(): Nullable<Effect>;
  15250. private _disposeTextures;
  15251. /**
  15252. * Disposes the post process.
  15253. * @param camera The camera to dispose the post process on.
  15254. */
  15255. dispose(camera?: Camera): void;
  15256. }
  15257. }
  15258. declare module BABYLON {
  15259. /** @hidden */
  15260. export var kernelBlurVaryingDeclaration: {
  15261. name: string;
  15262. shader: string;
  15263. };
  15264. }
  15265. declare module BABYLON {
  15266. /** @hidden */
  15267. export var kernelBlurFragment: {
  15268. name: string;
  15269. shader: string;
  15270. };
  15271. }
  15272. declare module BABYLON {
  15273. /** @hidden */
  15274. export var kernelBlurFragment2: {
  15275. name: string;
  15276. shader: string;
  15277. };
  15278. }
  15279. declare module BABYLON {
  15280. /** @hidden */
  15281. export var kernelBlurPixelShader: {
  15282. name: string;
  15283. shader: string;
  15284. };
  15285. }
  15286. declare module BABYLON {
  15287. /** @hidden */
  15288. export var kernelBlurVertex: {
  15289. name: string;
  15290. shader: string;
  15291. };
  15292. }
  15293. declare module BABYLON {
  15294. /** @hidden */
  15295. export var kernelBlurVertexShader: {
  15296. name: string;
  15297. shader: string;
  15298. };
  15299. }
  15300. declare module BABYLON {
  15301. /**
  15302. * The Blur Post Process which blurs an image based on a kernel and direction.
  15303. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15304. */
  15305. export class BlurPostProcess extends PostProcess {
  15306. /** The direction in which to blur the image. */
  15307. direction: Vector2;
  15308. private blockCompilation;
  15309. protected _kernel: number;
  15310. protected _idealKernel: number;
  15311. protected _packedFloat: boolean;
  15312. private _staticDefines;
  15313. /**
  15314. * Sets the length in pixels of the blur sample region
  15315. */
  15316. /**
  15317. * Gets the length in pixels of the blur sample region
  15318. */
  15319. kernel: number;
  15320. /**
  15321. * Sets wether or not the blur needs to unpack/repack floats
  15322. */
  15323. /**
  15324. * Gets wether or not the blur is unpacking/repacking floats
  15325. */
  15326. packedFloat: boolean;
  15327. /**
  15328. * Creates a new instance BlurPostProcess
  15329. * @param name The name of the effect.
  15330. * @param direction The direction in which to blur the image.
  15331. * @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.
  15332. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15333. * @param camera The camera to apply the render pass to.
  15334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15335. * @param engine The engine which the post process will be applied. (default: current engine)
  15336. * @param reusable If the post process can be reused on the same frame. (default: false)
  15337. * @param textureType Type of textures used when performing the post process. (default: 0)
  15338. * @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)
  15339. */
  15340. constructor(name: string,
  15341. /** The direction in which to blur the image. */
  15342. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15343. /**
  15344. * Updates the effect with the current post process compile time values and recompiles the shader.
  15345. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15346. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15347. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15348. * @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
  15349. * @param onCompiled Called when the shader has been compiled.
  15350. * @param onError Called if there is an error when compiling a shader.
  15351. */
  15352. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15353. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15354. /**
  15355. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15356. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15357. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15358. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15359. * The gaps between physical kernels are compensated for in the weighting of the samples
  15360. * @param idealKernel Ideal blur kernel.
  15361. * @return Nearest best kernel.
  15362. */
  15363. protected _nearestBestKernel(idealKernel: number): number;
  15364. /**
  15365. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15366. * @param x The point on the Gaussian distribution to sample.
  15367. * @return the value of the Gaussian function at x.
  15368. */
  15369. protected _gaussianWeight(x: number): number;
  15370. /**
  15371. * Generates a string that can be used as a floating point number in GLSL.
  15372. * @param x Value to print.
  15373. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15374. * @return GLSL float string.
  15375. */
  15376. protected _glslFloat(x: number, decimalFigures?: number): string;
  15377. }
  15378. }
  15379. declare module BABYLON {
  15380. /**
  15381. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15382. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15383. * You can then easily use it as a reflectionTexture on a flat surface.
  15384. * In case the surface is not a plane, please consider relying on reflection probes.
  15385. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15386. */
  15387. export class MirrorTexture extends RenderTargetTexture {
  15388. private scene;
  15389. /**
  15390. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15391. * 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.
  15392. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15393. */
  15394. mirrorPlane: Plane;
  15395. /**
  15396. * Define the blur ratio used to blur the reflection if needed.
  15397. */
  15398. blurRatio: number;
  15399. /**
  15400. * Define the adaptive blur kernel used to blur the reflection if needed.
  15401. * This will autocompute the closest best match for the `blurKernel`
  15402. */
  15403. adaptiveBlurKernel: number;
  15404. /**
  15405. * Define the blur kernel used to blur the reflection if needed.
  15406. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15407. */
  15408. blurKernel: number;
  15409. /**
  15410. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15411. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15412. */
  15413. blurKernelX: number;
  15414. /**
  15415. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15416. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15417. */
  15418. blurKernelY: number;
  15419. private _autoComputeBlurKernel;
  15420. protected _onRatioRescale(): void;
  15421. private _updateGammaSpace;
  15422. private _imageProcessingConfigChangeObserver;
  15423. private _transformMatrix;
  15424. private _mirrorMatrix;
  15425. private _savedViewMatrix;
  15426. private _blurX;
  15427. private _blurY;
  15428. private _adaptiveBlurKernel;
  15429. private _blurKernelX;
  15430. private _blurKernelY;
  15431. private _blurRatio;
  15432. /**
  15433. * Instantiates a Mirror Texture.
  15434. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15435. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15436. * You can then easily use it as a reflectionTexture on a flat surface.
  15437. * In case the surface is not a plane, please consider relying on reflection probes.
  15438. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15439. * @param name
  15440. * @param size
  15441. * @param scene
  15442. * @param generateMipMaps
  15443. * @param type
  15444. * @param samplingMode
  15445. * @param generateDepthBuffer
  15446. */
  15447. constructor(name: string, size: number | {
  15448. width: number;
  15449. height: number;
  15450. } | {
  15451. ratio: number;
  15452. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15453. private _preparePostProcesses;
  15454. /**
  15455. * Clone the mirror texture.
  15456. * @returns the cloned texture
  15457. */
  15458. clone(): MirrorTexture;
  15459. /**
  15460. * Serialize the texture to a JSON representation you could use in Parse later on
  15461. * @returns the serialized JSON representation
  15462. */
  15463. serialize(): any;
  15464. /**
  15465. * Dispose the texture and release its associated resources.
  15466. */
  15467. dispose(): void;
  15468. }
  15469. }
  15470. declare module BABYLON {
  15471. /**
  15472. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15473. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15474. */
  15475. export class Texture extends BaseTexture {
  15476. /** @hidden */
  15477. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15478. /** @hidden */
  15479. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15480. /** @hidden */
  15481. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15482. /** nearest is mag = nearest and min = nearest and mip = linear */
  15483. static readonly NEAREST_SAMPLINGMODE: number;
  15484. /** nearest is mag = nearest and min = nearest and mip = linear */
  15485. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15486. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15487. static readonly BILINEAR_SAMPLINGMODE: number;
  15488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15489. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15490. /** Trilinear is mag = linear and min = linear and mip = linear */
  15491. static readonly TRILINEAR_SAMPLINGMODE: number;
  15492. /** Trilinear is mag = linear and min = linear and mip = linear */
  15493. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15494. /** mag = nearest and min = nearest and mip = nearest */
  15495. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15496. /** mag = nearest and min = linear and mip = nearest */
  15497. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15498. /** mag = nearest and min = linear and mip = linear */
  15499. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15500. /** mag = nearest and min = linear and mip = none */
  15501. static readonly NEAREST_LINEAR: number;
  15502. /** mag = nearest and min = nearest and mip = none */
  15503. static readonly NEAREST_NEAREST: number;
  15504. /** mag = linear and min = nearest and mip = nearest */
  15505. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15506. /** mag = linear and min = nearest and mip = linear */
  15507. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15508. /** mag = linear and min = linear and mip = none */
  15509. static readonly LINEAR_LINEAR: number;
  15510. /** mag = linear and min = nearest and mip = none */
  15511. static readonly LINEAR_NEAREST: number;
  15512. /** Explicit coordinates mode */
  15513. static readonly EXPLICIT_MODE: number;
  15514. /** Spherical coordinates mode */
  15515. static readonly SPHERICAL_MODE: number;
  15516. /** Planar coordinates mode */
  15517. static readonly PLANAR_MODE: number;
  15518. /** Cubic coordinates mode */
  15519. static readonly CUBIC_MODE: number;
  15520. /** Projection coordinates mode */
  15521. static readonly PROJECTION_MODE: number;
  15522. /** Inverse Cubic coordinates mode */
  15523. static readonly SKYBOX_MODE: number;
  15524. /** Inverse Cubic coordinates mode */
  15525. static readonly INVCUBIC_MODE: number;
  15526. /** Equirectangular coordinates mode */
  15527. static readonly EQUIRECTANGULAR_MODE: number;
  15528. /** Equirectangular Fixed coordinates mode */
  15529. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15530. /** Equirectangular Fixed Mirrored coordinates mode */
  15531. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15532. /** Texture is not repeating outside of 0..1 UVs */
  15533. static readonly CLAMP_ADDRESSMODE: number;
  15534. /** Texture is repeating outside of 0..1 UVs */
  15535. static readonly WRAP_ADDRESSMODE: number;
  15536. /** Texture is repeating and mirrored */
  15537. static readonly MIRROR_ADDRESSMODE: number;
  15538. /**
  15539. * 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
  15540. */
  15541. static UseSerializedUrlIfAny: boolean;
  15542. /**
  15543. * Define the url of the texture.
  15544. */
  15545. url: Nullable<string>;
  15546. /**
  15547. * Define an offset on the texture to offset the u coordinates of the UVs
  15548. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15549. */
  15550. uOffset: number;
  15551. /**
  15552. * Define an offset on the texture to offset the v coordinates of the UVs
  15553. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15554. */
  15555. vOffset: number;
  15556. /**
  15557. * Define an offset on the texture to scale the u coordinates of the UVs
  15558. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15559. */
  15560. uScale: number;
  15561. /**
  15562. * Define an offset on the texture to scale the v coordinates of the UVs
  15563. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15564. */
  15565. vScale: number;
  15566. /**
  15567. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15568. * @see http://doc.babylonjs.com/how_to/more_materials
  15569. */
  15570. uAng: number;
  15571. /**
  15572. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15573. * @see http://doc.babylonjs.com/how_to/more_materials
  15574. */
  15575. vAng: number;
  15576. /**
  15577. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15578. * @see http://doc.babylonjs.com/how_to/more_materials
  15579. */
  15580. wAng: number;
  15581. /**
  15582. * Defines the center of rotation (U)
  15583. */
  15584. uRotationCenter: number;
  15585. /**
  15586. * Defines the center of rotation (V)
  15587. */
  15588. vRotationCenter: number;
  15589. /**
  15590. * Defines the center of rotation (W)
  15591. */
  15592. wRotationCenter: number;
  15593. /**
  15594. * Are mip maps generated for this texture or not.
  15595. */
  15596. readonly noMipmap: boolean;
  15597. /**
  15598. * List of inspectable custom properties (used by the Inspector)
  15599. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15600. */
  15601. inspectableCustomProperties: Nullable<IInspectable[]>;
  15602. private _noMipmap;
  15603. /** @hidden */
  15604. _invertY: boolean;
  15605. private _rowGenerationMatrix;
  15606. private _cachedTextureMatrix;
  15607. private _projectionModeMatrix;
  15608. private _t0;
  15609. private _t1;
  15610. private _t2;
  15611. private _cachedUOffset;
  15612. private _cachedVOffset;
  15613. private _cachedUScale;
  15614. private _cachedVScale;
  15615. private _cachedUAng;
  15616. private _cachedVAng;
  15617. private _cachedWAng;
  15618. private _cachedProjectionMatrixId;
  15619. private _cachedCoordinatesMode;
  15620. /** @hidden */
  15621. protected _initialSamplingMode: number;
  15622. /** @hidden */
  15623. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15624. private _deleteBuffer;
  15625. protected _format: Nullable<number>;
  15626. private _delayedOnLoad;
  15627. private _delayedOnError;
  15628. /**
  15629. * Observable triggered once the texture has been loaded.
  15630. */
  15631. onLoadObservable: Observable<Texture>;
  15632. protected _isBlocking: boolean;
  15633. /**
  15634. * Is the texture preventing material to render while loading.
  15635. * If false, a default texture will be used instead of the loading one during the preparation step.
  15636. */
  15637. isBlocking: boolean;
  15638. /**
  15639. * Get the current sampling mode associated with the texture.
  15640. */
  15641. readonly samplingMode: number;
  15642. /**
  15643. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15644. */
  15645. readonly invertY: boolean;
  15646. /**
  15647. * Instantiates a new texture.
  15648. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15649. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15650. * @param url define the url of the picture to load as a texture
  15651. * @param scene define the scene or engine the texture will belong to
  15652. * @param noMipmap define if the texture will require mip maps or not
  15653. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15654. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15655. * @param onLoad define a callback triggered when the texture has been loaded
  15656. * @param onError define a callback triggered when an error occurred during the loading session
  15657. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15658. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15659. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15660. */
  15661. 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);
  15662. /**
  15663. * Update the url (and optional buffer) of this texture if url was null during construction.
  15664. * @param url the url of the texture
  15665. * @param buffer the buffer of the texture (defaults to null)
  15666. * @param onLoad callback called when the texture is loaded (defaults to null)
  15667. */
  15668. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15669. /**
  15670. * Finish the loading sequence of a texture flagged as delayed load.
  15671. * @hidden
  15672. */
  15673. delayLoad(): void;
  15674. private _prepareRowForTextureGeneration;
  15675. /**
  15676. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15677. * @returns the transform matrix of the texture.
  15678. */
  15679. getTextureMatrix(): Matrix;
  15680. /**
  15681. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15682. * @returns The reflection texture transform
  15683. */
  15684. getReflectionTextureMatrix(): Matrix;
  15685. /**
  15686. * Clones the texture.
  15687. * @returns the cloned texture
  15688. */
  15689. clone(): Texture;
  15690. /**
  15691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15692. * @returns The JSON representation of the texture
  15693. */
  15694. serialize(): any;
  15695. /**
  15696. * Get the current class name of the texture useful for serialization or dynamic coding.
  15697. * @returns "Texture"
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Dispose the texture and release its associated resources.
  15702. */
  15703. dispose(): void;
  15704. /**
  15705. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15706. * @param parsedTexture Define the JSON representation of the texture
  15707. * @param scene Define the scene the parsed texture should be instantiated in
  15708. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15709. * @returns The parsed texture if successful
  15710. */
  15711. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15712. /**
  15713. * Creates a texture from its base 64 representation.
  15714. * @param data Define the base64 payload without the data: prefix
  15715. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15716. * @param scene Define the scene the texture should belong to
  15717. * @param noMipmap Forces the texture to not create mip map information if true
  15718. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15719. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15720. * @param onLoad define a callback triggered when the texture has been loaded
  15721. * @param onError define a callback triggered when an error occurred during the loading session
  15722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15723. * @returns the created texture
  15724. */
  15725. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15726. /**
  15727. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15728. * @param data Define the base64 payload without the data: prefix
  15729. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15730. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15731. * @param scene Define the scene the texture should belong to
  15732. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15733. * @param noMipmap Forces the texture to not create mip map information if true
  15734. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15735. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15736. * @param onLoad define a callback triggered when the texture has been loaded
  15737. * @param onError define a callback triggered when an error occurred during the loading session
  15738. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15739. * @returns the created texture
  15740. */
  15741. 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;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15748. */
  15749. export class PostProcessManager {
  15750. private _scene;
  15751. private _indexBuffer;
  15752. private _vertexBuffers;
  15753. /**
  15754. * Creates a new instance PostProcess
  15755. * @param scene The scene that the post process is associated with.
  15756. */
  15757. constructor(scene: Scene);
  15758. private _prepareBuffers;
  15759. private _buildIndexBuffer;
  15760. /**
  15761. * Rebuilds the vertex buffers of the manager.
  15762. * @hidden
  15763. */
  15764. _rebuild(): void;
  15765. /**
  15766. * Prepares a frame to be run through a post process.
  15767. * @param sourceTexture The input texture to the post procesess. (default: null)
  15768. * @param postProcesses An array of post processes to be run. (default: null)
  15769. * @returns True if the post processes were able to be run.
  15770. * @hidden
  15771. */
  15772. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15773. /**
  15774. * Manually render a set of post processes to a texture.
  15775. * @param postProcesses An array of post processes to be run.
  15776. * @param targetTexture The target texture to render to.
  15777. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15778. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15779. * @param lodLevel defines which lod of the texture to render to
  15780. */
  15781. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15782. /**
  15783. * Finalize the result of the output of the postprocesses.
  15784. * @param doNotPresent If true the result will not be displayed to the screen.
  15785. * @param targetTexture The target texture to render to.
  15786. * @param faceIndex The index of the face to bind the target texture to.
  15787. * @param postProcesses The array of post processes to render.
  15788. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15789. * @hidden
  15790. */
  15791. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15792. /**
  15793. * Disposes of the post process manager.
  15794. */
  15795. dispose(): void;
  15796. }
  15797. }
  15798. declare module BABYLON {
  15799. /** Interface used by value gradients (color, factor, ...) */
  15800. export interface IValueGradient {
  15801. /**
  15802. * Gets or sets the gradient value (between 0 and 1)
  15803. */
  15804. gradient: number;
  15805. }
  15806. /** Class used to store color4 gradient */
  15807. export class ColorGradient implements IValueGradient {
  15808. /**
  15809. * Gets or sets the gradient value (between 0 and 1)
  15810. */
  15811. gradient: number;
  15812. /**
  15813. * Gets or sets first associated color
  15814. */
  15815. color1: Color4;
  15816. /**
  15817. * Gets or sets second associated color
  15818. */
  15819. color2?: Color4;
  15820. /**
  15821. * Will get a color picked randomly between color1 and color2.
  15822. * If color2 is undefined then color1 will be used
  15823. * @param result defines the target Color4 to store the result in
  15824. */
  15825. getColorToRef(result: Color4): void;
  15826. }
  15827. /** Class used to store color 3 gradient */
  15828. export class Color3Gradient implements IValueGradient {
  15829. /**
  15830. * Gets or sets the gradient value (between 0 and 1)
  15831. */
  15832. gradient: number;
  15833. /**
  15834. * Gets or sets the associated color
  15835. */
  15836. color: Color3;
  15837. }
  15838. /** Class used to store factor gradient */
  15839. export class FactorGradient implements IValueGradient {
  15840. /**
  15841. * Gets or sets the gradient value (between 0 and 1)
  15842. */
  15843. gradient: number;
  15844. /**
  15845. * Gets or sets first associated factor
  15846. */
  15847. factor1: number;
  15848. /**
  15849. * Gets or sets second associated factor
  15850. */
  15851. factor2?: number;
  15852. /**
  15853. * Will get a number picked randomly between factor1 and factor2.
  15854. * If factor2 is undefined then factor1 will be used
  15855. * @returns the picked number
  15856. */
  15857. getFactor(): number;
  15858. }
  15859. /**
  15860. * Helper used to simplify some generic gradient tasks
  15861. */
  15862. export class GradientHelper {
  15863. /**
  15864. * Gets the current gradient from an array of IValueGradient
  15865. * @param ratio defines the current ratio to get
  15866. * @param gradients defines the array of IValueGradient
  15867. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15868. */
  15869. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15870. }
  15871. }
  15872. declare module BABYLON {
  15873. interface AbstractScene {
  15874. /**
  15875. * The list of procedural textures added to the scene
  15876. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15877. */
  15878. proceduralTextures: Array<ProceduralTexture>;
  15879. }
  15880. /**
  15881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15882. * in a given scene.
  15883. */
  15884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15885. /**
  15886. * The component name helpfull to identify the component in the list of scene components.
  15887. */
  15888. readonly name: string;
  15889. /**
  15890. * The scene the component belongs to.
  15891. */
  15892. scene: Scene;
  15893. /**
  15894. * Creates a new instance of the component for the given scene
  15895. * @param scene Defines the scene to register the component in
  15896. */
  15897. constructor(scene: Scene);
  15898. /**
  15899. * Registers the component in a given scene
  15900. */
  15901. register(): void;
  15902. /**
  15903. * Rebuilds the elements related to this component in case of
  15904. * context lost for instance.
  15905. */
  15906. rebuild(): void;
  15907. /**
  15908. * Disposes the component and the associated ressources.
  15909. */
  15910. dispose(): void;
  15911. private _beforeClear;
  15912. }
  15913. }
  15914. declare module BABYLON {
  15915. interface Engine {
  15916. /**
  15917. * Creates a new render target cube texture
  15918. * @param size defines the size of the texture
  15919. * @param options defines the options used to create the texture
  15920. * @returns a new render target cube texture stored in an InternalTexture
  15921. */
  15922. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15923. }
  15924. }
  15925. declare module BABYLON {
  15926. /** @hidden */
  15927. export var proceduralVertexShader: {
  15928. name: string;
  15929. shader: string;
  15930. };
  15931. }
  15932. declare module BABYLON {
  15933. /**
  15934. * 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.
  15935. * This is the base class of any Procedural texture and contains most of the shareable code.
  15936. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15937. */
  15938. export class ProceduralTexture extends Texture {
  15939. isCube: boolean;
  15940. /**
  15941. * Define if the texture is enabled or not (disabled texture will not render)
  15942. */
  15943. isEnabled: boolean;
  15944. /**
  15945. * Define if the texture must be cleared before rendering (default is true)
  15946. */
  15947. autoClear: boolean;
  15948. /**
  15949. * Callback called when the texture is generated
  15950. */
  15951. onGenerated: () => void;
  15952. /**
  15953. * Event raised when the texture is generated
  15954. */
  15955. onGeneratedObservable: Observable<ProceduralTexture>;
  15956. /** @hidden */
  15957. _generateMipMaps: boolean;
  15958. /** @hidden **/
  15959. _effect: Effect;
  15960. /** @hidden */
  15961. _textures: {
  15962. [key: string]: Texture;
  15963. };
  15964. private _size;
  15965. private _currentRefreshId;
  15966. private _refreshRate;
  15967. private _vertexBuffers;
  15968. private _indexBuffer;
  15969. private _uniforms;
  15970. private _samplers;
  15971. private _fragment;
  15972. private _floats;
  15973. private _ints;
  15974. private _floatsArrays;
  15975. private _colors3;
  15976. private _colors4;
  15977. private _vectors2;
  15978. private _vectors3;
  15979. private _matrices;
  15980. private _fallbackTexture;
  15981. private _fallbackTextureUsed;
  15982. private _engine;
  15983. private _cachedDefines;
  15984. private _contentUpdateId;
  15985. private _contentData;
  15986. /**
  15987. * Instantiates a new procedural texture.
  15988. * 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.
  15989. * This is the base class of any Procedural texture and contains most of the shareable code.
  15990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15991. * @param name Define the name of the texture
  15992. * @param size Define the size of the texture to create
  15993. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15994. * @param scene Define the scene the texture belongs to
  15995. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15996. * @param generateMipMaps Define if the texture should creates mip maps or not
  15997. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15998. */
  15999. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16000. /**
  16001. * The effect that is created when initializing the post process.
  16002. * @returns The created effect corresponding the the postprocess.
  16003. */
  16004. getEffect(): Effect;
  16005. /**
  16006. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16007. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16008. */
  16009. getContent(): Nullable<ArrayBufferView>;
  16010. private _createIndexBuffer;
  16011. /** @hidden */
  16012. _rebuild(): void;
  16013. /**
  16014. * Resets the texture in order to recreate its associated resources.
  16015. * This can be called in case of context loss
  16016. */
  16017. reset(): void;
  16018. protected _getDefines(): string;
  16019. /**
  16020. * Is the texture ready to be used ? (rendered at least once)
  16021. * @returns true if ready, otherwise, false.
  16022. */
  16023. isReady(): boolean;
  16024. /**
  16025. * Resets the refresh counter of the texture and start bak from scratch.
  16026. * Could be useful to regenerate the texture if it is setup to render only once.
  16027. */
  16028. resetRefreshCounter(): void;
  16029. /**
  16030. * Set the fragment shader to use in order to render the texture.
  16031. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16032. */
  16033. setFragment(fragment: any): void;
  16034. /**
  16035. * Define the refresh rate of the texture or the rendering frequency.
  16036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16037. */
  16038. refreshRate: number;
  16039. /** @hidden */
  16040. _shouldRender(): boolean;
  16041. /**
  16042. * Get the size the texture is rendering at.
  16043. * @returns the size (texture is always squared)
  16044. */
  16045. getRenderSize(): number;
  16046. /**
  16047. * Resize the texture to new value.
  16048. * @param size Define the new size the texture should have
  16049. * @param generateMipMaps Define whether the new texture should create mip maps
  16050. */
  16051. resize(size: number, generateMipMaps: boolean): void;
  16052. private _checkUniform;
  16053. /**
  16054. * Set a texture in the shader program used to render.
  16055. * @param name Define the name of the uniform samplers as defined in the shader
  16056. * @param texture Define the texture to bind to this sampler
  16057. * @return the texture itself allowing "fluent" like uniform updates
  16058. */
  16059. setTexture(name: string, texture: Texture): ProceduralTexture;
  16060. /**
  16061. * Set a float in the shader.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the texture itself allowing "fluent" like uniform updates
  16065. */
  16066. setFloat(name: string, value: number): ProceduralTexture;
  16067. /**
  16068. * Set a int in the shader.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the texture itself allowing "fluent" like uniform updates
  16072. */
  16073. setInt(name: string, value: number): ProceduralTexture;
  16074. /**
  16075. * Set an array of floats in the shader.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the texture itself allowing "fluent" like uniform updates
  16079. */
  16080. setFloats(name: string, value: number[]): ProceduralTexture;
  16081. /**
  16082. * Set a vec3 in the shader from a Color3.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the texture itself allowing "fluent" like uniform updates
  16086. */
  16087. setColor3(name: string, value: Color3): ProceduralTexture;
  16088. /**
  16089. * Set a vec4 in the shader from a Color4.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the texture itself allowing "fluent" like uniform updates
  16093. */
  16094. setColor4(name: string, value: Color4): ProceduralTexture;
  16095. /**
  16096. * Set a vec2 in the shader from a Vector2.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the texture itself allowing "fluent" like uniform updates
  16100. */
  16101. setVector2(name: string, value: Vector2): ProceduralTexture;
  16102. /**
  16103. * Set a vec3 in the shader from a Vector3.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the texture itself allowing "fluent" like uniform updates
  16107. */
  16108. setVector3(name: string, value: Vector3): ProceduralTexture;
  16109. /**
  16110. * Set a mat4 in the shader from a MAtrix.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the texture itself allowing "fluent" like uniform updates
  16114. */
  16115. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16116. /**
  16117. * Render the texture to its associated render target.
  16118. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16119. */
  16120. render(useCameraPostProcess?: boolean): void;
  16121. /**
  16122. * Clone the texture.
  16123. * @returns the cloned texture
  16124. */
  16125. clone(): ProceduralTexture;
  16126. /**
  16127. * Dispose the texture and release its asoociated resources.
  16128. */
  16129. dispose(): void;
  16130. }
  16131. }
  16132. declare module BABYLON {
  16133. /**
  16134. * This represents the base class for particle system in Babylon.
  16135. * 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.
  16136. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16137. * @example https://doc.babylonjs.com/babylon101/particles
  16138. */
  16139. export class BaseParticleSystem {
  16140. /**
  16141. * Source color is added to the destination color without alpha affecting the result
  16142. */
  16143. static BLENDMODE_ONEONE: number;
  16144. /**
  16145. * Blend current color and particle color using particle’s alpha
  16146. */
  16147. static BLENDMODE_STANDARD: number;
  16148. /**
  16149. * Add current color and particle color multiplied by particle’s alpha
  16150. */
  16151. static BLENDMODE_ADD: number;
  16152. /**
  16153. * Multiply current color with particle color
  16154. */
  16155. static BLENDMODE_MULTIPLY: number;
  16156. /**
  16157. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16158. */
  16159. static BLENDMODE_MULTIPLYADD: number;
  16160. /**
  16161. * List of animations used by the particle system.
  16162. */
  16163. animations: Animation[];
  16164. /**
  16165. * The id of the Particle system.
  16166. */
  16167. id: string;
  16168. /**
  16169. * The friendly name of the Particle system.
  16170. */
  16171. name: string;
  16172. /**
  16173. * The rendering group used by the Particle system to chose when to render.
  16174. */
  16175. renderingGroupId: number;
  16176. /**
  16177. * The emitter represents the Mesh or position we are attaching the particle system to.
  16178. */
  16179. emitter: Nullable<AbstractMesh | Vector3>;
  16180. /**
  16181. * The maximum number of particles to emit per frame
  16182. */
  16183. emitRate: number;
  16184. /**
  16185. * If you want to launch only a few particles at once, that can be done, as well.
  16186. */
  16187. manualEmitCount: number;
  16188. /**
  16189. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16190. */
  16191. updateSpeed: number;
  16192. /**
  16193. * The amount of time the particle system is running (depends of the overall update speed).
  16194. */
  16195. targetStopDuration: number;
  16196. /**
  16197. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16198. */
  16199. disposeOnStop: boolean;
  16200. /**
  16201. * Minimum power of emitting particles.
  16202. */
  16203. minEmitPower: number;
  16204. /**
  16205. * Maximum power of emitting particles.
  16206. */
  16207. maxEmitPower: number;
  16208. /**
  16209. * Minimum life time of emitting particles.
  16210. */
  16211. minLifeTime: number;
  16212. /**
  16213. * Maximum life time of emitting particles.
  16214. */
  16215. maxLifeTime: number;
  16216. /**
  16217. * Minimum Size of emitting particles.
  16218. */
  16219. minSize: number;
  16220. /**
  16221. * Maximum Size of emitting particles.
  16222. */
  16223. maxSize: number;
  16224. /**
  16225. * Minimum scale of emitting particles on X axis.
  16226. */
  16227. minScaleX: number;
  16228. /**
  16229. * Maximum scale of emitting particles on X axis.
  16230. */
  16231. maxScaleX: number;
  16232. /**
  16233. * Minimum scale of emitting particles on Y axis.
  16234. */
  16235. minScaleY: number;
  16236. /**
  16237. * Maximum scale of emitting particles on Y axis.
  16238. */
  16239. maxScaleY: number;
  16240. /**
  16241. * Gets or sets the minimal initial rotation in radians.
  16242. */
  16243. minInitialRotation: number;
  16244. /**
  16245. * Gets or sets the maximal initial rotation in radians.
  16246. */
  16247. maxInitialRotation: number;
  16248. /**
  16249. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16250. */
  16251. minAngularSpeed: number;
  16252. /**
  16253. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16254. */
  16255. maxAngularSpeed: number;
  16256. /**
  16257. * The texture used to render each particle. (this can be a spritesheet)
  16258. */
  16259. particleTexture: Nullable<Texture>;
  16260. /**
  16261. * The layer mask we are rendering the particles through.
  16262. */
  16263. layerMask: number;
  16264. /**
  16265. * This can help using your own shader to render the particle system.
  16266. * The according effect will be created
  16267. */
  16268. customShader: any;
  16269. /**
  16270. * By default particle system starts as soon as they are created. This prevents the
  16271. * automatic start to happen and let you decide when to start emitting particles.
  16272. */
  16273. preventAutoStart: boolean;
  16274. private _noiseTexture;
  16275. /**
  16276. * Gets or sets a texture used to add random noise to particle positions
  16277. */
  16278. noiseTexture: Nullable<ProceduralTexture>;
  16279. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16280. noiseStrength: Vector3;
  16281. /**
  16282. * Callback triggered when the particle animation is ending.
  16283. */
  16284. onAnimationEnd: Nullable<() => void>;
  16285. /**
  16286. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16287. */
  16288. blendMode: number;
  16289. /**
  16290. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16291. * to override the particles.
  16292. */
  16293. forceDepthWrite: boolean;
  16294. /** 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 */
  16295. preWarmCycles: number;
  16296. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16297. preWarmStepOffset: number;
  16298. /**
  16299. * 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)
  16300. */
  16301. spriteCellChangeSpeed: number;
  16302. /**
  16303. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16304. */
  16305. startSpriteCellID: number;
  16306. /**
  16307. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16308. */
  16309. endSpriteCellID: number;
  16310. /**
  16311. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16312. */
  16313. spriteCellWidth: number;
  16314. /**
  16315. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16316. */
  16317. spriteCellHeight: number;
  16318. /**
  16319. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16320. */
  16321. spriteRandomStartCell: boolean;
  16322. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16323. translationPivot: Vector2;
  16324. /** @hidden */
  16325. protected _isAnimationSheetEnabled: boolean;
  16326. /**
  16327. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16328. */
  16329. beginAnimationOnStart: boolean;
  16330. /**
  16331. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16332. */
  16333. beginAnimationFrom: number;
  16334. /**
  16335. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16336. */
  16337. beginAnimationTo: number;
  16338. /**
  16339. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16340. */
  16341. beginAnimationLoop: boolean;
  16342. /**
  16343. * Gets or sets a world offset applied to all particles
  16344. */
  16345. worldOffset: Vector3;
  16346. /**
  16347. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16348. */
  16349. isAnimationSheetEnabled: boolean;
  16350. /**
  16351. * Get hosting scene
  16352. * @returns the scene
  16353. */
  16354. getScene(): Scene;
  16355. /**
  16356. * You can use gravity if you want to give an orientation to your particles.
  16357. */
  16358. gravity: Vector3;
  16359. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16360. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16361. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16362. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16363. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16364. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16365. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16366. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16367. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16368. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16369. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16370. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16371. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16372. /**
  16373. * Defines the delay in milliseconds before starting the system (0 by default)
  16374. */
  16375. startDelay: number;
  16376. /**
  16377. * Gets the current list of drag gradients.
  16378. * You must use addDragGradient and removeDragGradient to udpate this list
  16379. * @returns the list of drag gradients
  16380. */
  16381. getDragGradients(): Nullable<Array<FactorGradient>>;
  16382. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16383. limitVelocityDamping: number;
  16384. /**
  16385. * Gets the current list of limit velocity gradients.
  16386. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16387. * @returns the list of limit velocity gradients
  16388. */
  16389. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Gets the current list of color gradients.
  16392. * You must use addColorGradient and removeColorGradient to udpate this list
  16393. * @returns the list of color gradients
  16394. */
  16395. getColorGradients(): Nullable<Array<ColorGradient>>;
  16396. /**
  16397. * Gets the current list of size gradients.
  16398. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16399. * @returns the list of size gradients
  16400. */
  16401. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16402. /**
  16403. * Gets the current list of color remap gradients.
  16404. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16405. * @returns the list of color remap gradients
  16406. */
  16407. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16408. /**
  16409. * Gets the current list of alpha remap gradients.
  16410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16411. * @returns the list of alpha remap gradients
  16412. */
  16413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16414. /**
  16415. * Gets the current list of life time gradients.
  16416. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16417. * @returns the list of life time gradients
  16418. */
  16419. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16420. /**
  16421. * Gets the current list of angular speed gradients.
  16422. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16423. * @returns the list of angular speed gradients
  16424. */
  16425. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16426. /**
  16427. * Gets the current list of velocity gradients.
  16428. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16429. * @returns the list of velocity gradients
  16430. */
  16431. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of start size gradients.
  16434. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16435. * @returns the list of start size gradients
  16436. */
  16437. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16438. /**
  16439. * Gets the current list of emit rate gradients.
  16440. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16441. * @returns the list of emit rate gradients
  16442. */
  16443. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16447. */
  16448. direction1: Vector3;
  16449. /**
  16450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16452. */
  16453. direction2: Vector3;
  16454. /**
  16455. * 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.
  16456. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16457. */
  16458. minEmitBox: Vector3;
  16459. /**
  16460. * 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.
  16461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16462. */
  16463. maxEmitBox: Vector3;
  16464. /**
  16465. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16466. */
  16467. color1: Color4;
  16468. /**
  16469. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16470. */
  16471. color2: Color4;
  16472. /**
  16473. * Color the particle will have at the end of its lifetime
  16474. */
  16475. colorDead: Color4;
  16476. /**
  16477. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16478. */
  16479. textureMask: Color4;
  16480. /**
  16481. * The particle emitter type defines the emitter used by the particle system.
  16482. * It can be for example box, sphere, or cone...
  16483. */
  16484. particleEmitterType: IParticleEmitterType;
  16485. /** @hidden */
  16486. _isSubEmitter: boolean;
  16487. /**
  16488. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16489. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16490. */
  16491. billboardMode: number;
  16492. protected _isBillboardBased: boolean;
  16493. /**
  16494. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16495. */
  16496. isBillboardBased: boolean;
  16497. /**
  16498. * The scene the particle system belongs to.
  16499. */
  16500. protected _scene: Scene;
  16501. /**
  16502. * Local cache of defines for image processing.
  16503. */
  16504. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16505. /**
  16506. * Default configuration related to image processing available in the standard Material.
  16507. */
  16508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16509. /**
  16510. * Gets the image processing configuration used either in this material.
  16511. */
  16512. /**
  16513. * Sets the Default image processing configuration used either in the this material.
  16514. *
  16515. * If sets to null, the scene one is in use.
  16516. */
  16517. imageProcessingConfiguration: ImageProcessingConfiguration;
  16518. /**
  16519. * Attaches a new image processing configuration to the Standard Material.
  16520. * @param configuration
  16521. */
  16522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16523. /** @hidden */
  16524. protected _reset(): void;
  16525. /** @hidden */
  16526. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16527. /**
  16528. * Instantiates a particle system.
  16529. * 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.
  16530. * @param name The name of the particle system
  16531. */
  16532. constructor(name: string);
  16533. /**
  16534. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16537. * @returns the emitter
  16538. */
  16539. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16540. /**
  16541. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16542. * @param radius The radius of the hemisphere to emit from
  16543. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16544. * @returns the emitter
  16545. */
  16546. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16547. /**
  16548. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16549. * @param radius The radius of the sphere to emit from
  16550. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16551. * @returns the emitter
  16552. */
  16553. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16554. /**
  16555. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16556. * @param radius The radius of the sphere to emit from
  16557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16559. * @returns the emitter
  16560. */
  16561. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16562. /**
  16563. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16564. * @param radius The radius of the emission cylinder
  16565. * @param height The height of the emission cylinder
  16566. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16567. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16568. * @returns the emitter
  16569. */
  16570. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16571. /**
  16572. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16573. * @param radius The radius of the cylinder to emit from
  16574. * @param height The height of the emission cylinder
  16575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16576. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16577. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16578. * @returns the emitter
  16579. */
  16580. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16581. /**
  16582. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16583. * @param radius The radius of the cone to emit from
  16584. * @param angle The base angle of the cone
  16585. * @returns the emitter
  16586. */
  16587. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16588. /**
  16589. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16592. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16593. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16594. * @returns the emitter
  16595. */
  16596. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16597. }
  16598. }
  16599. declare module BABYLON {
  16600. /**
  16601. * Type of sub emitter
  16602. */
  16603. export enum SubEmitterType {
  16604. /**
  16605. * Attached to the particle over it's lifetime
  16606. */
  16607. ATTACHED = 0,
  16608. /**
  16609. * Created when the particle dies
  16610. */
  16611. END = 1
  16612. }
  16613. /**
  16614. * Sub emitter class used to emit particles from an existing particle
  16615. */
  16616. export class SubEmitter {
  16617. /**
  16618. * the particle system to be used by the sub emitter
  16619. */
  16620. particleSystem: ParticleSystem;
  16621. /**
  16622. * Type of the submitter (Default: END)
  16623. */
  16624. type: SubEmitterType;
  16625. /**
  16626. * 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)
  16627. * Note: This only is supported when using an emitter of type Mesh
  16628. */
  16629. inheritDirection: boolean;
  16630. /**
  16631. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16632. */
  16633. inheritedVelocityAmount: number;
  16634. /**
  16635. * Creates a sub emitter
  16636. * @param particleSystem the particle system to be used by the sub emitter
  16637. */
  16638. constructor(
  16639. /**
  16640. * the particle system to be used by the sub emitter
  16641. */
  16642. particleSystem: ParticleSystem);
  16643. /**
  16644. * Clones the sub emitter
  16645. * @returns the cloned sub emitter
  16646. */
  16647. clone(): SubEmitter;
  16648. /**
  16649. * Serialize current object to a JSON object
  16650. * @returns the serialized object
  16651. */
  16652. serialize(): any;
  16653. /** @hidden */
  16654. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16655. /**
  16656. * Creates a new SubEmitter from a serialized JSON version
  16657. * @param serializationObject defines the JSON object to read from
  16658. * @param scene defines the hosting scene
  16659. * @param rootUrl defines the rootUrl for data loading
  16660. * @returns a new SubEmitter
  16661. */
  16662. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16663. /** Release associated resources */
  16664. dispose(): void;
  16665. }
  16666. }
  16667. declare module BABYLON {
  16668. /** @hidden */
  16669. export var clipPlaneFragmentDeclaration: {
  16670. name: string;
  16671. shader: string;
  16672. };
  16673. }
  16674. declare module BABYLON {
  16675. /** @hidden */
  16676. export var imageProcessingDeclaration: {
  16677. name: string;
  16678. shader: string;
  16679. };
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var imageProcessingFunctions: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var clipPlaneFragment: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /** @hidden */
  16697. export var particlesPixelShader: {
  16698. name: string;
  16699. shader: string;
  16700. };
  16701. }
  16702. declare module BABYLON {
  16703. /** @hidden */
  16704. export var clipPlaneVertexDeclaration: {
  16705. name: string;
  16706. shader: string;
  16707. };
  16708. }
  16709. declare module BABYLON {
  16710. /** @hidden */
  16711. export var clipPlaneVertex: {
  16712. name: string;
  16713. shader: string;
  16714. };
  16715. }
  16716. declare module BABYLON {
  16717. /** @hidden */
  16718. export var particlesVertexShader: {
  16719. name: string;
  16720. shader: string;
  16721. };
  16722. }
  16723. declare module BABYLON {
  16724. /**
  16725. * This represents a particle system in Babylon.
  16726. * 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.
  16727. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16728. * @example https://doc.babylonjs.com/babylon101/particles
  16729. */
  16730. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16731. /**
  16732. * Billboard mode will only apply to Y axis
  16733. */
  16734. static readonly BILLBOARDMODE_Y: number;
  16735. /**
  16736. * Billboard mode will apply to all axes
  16737. */
  16738. static readonly BILLBOARDMODE_ALL: number;
  16739. /**
  16740. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16741. */
  16742. static readonly BILLBOARDMODE_STRETCHED: number;
  16743. /**
  16744. * This function can be defined to provide custom update for active particles.
  16745. * This function will be called instead of regular update (age, position, color, etc.).
  16746. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16747. */
  16748. updateFunction: (particles: Particle[]) => void;
  16749. private _emitterWorldMatrix;
  16750. /**
  16751. * This function can be defined to specify initial direction for every new particle.
  16752. * It by default use the emitterType defined function
  16753. */
  16754. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16755. /**
  16756. * This function can be defined to specify initial position for every new particle.
  16757. * It by default use the emitterType defined function
  16758. */
  16759. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16760. /**
  16761. * @hidden
  16762. */
  16763. _inheritedVelocityOffset: Vector3;
  16764. /**
  16765. * An event triggered when the system is disposed
  16766. */
  16767. onDisposeObservable: Observable<ParticleSystem>;
  16768. private _onDisposeObserver;
  16769. /**
  16770. * Sets a callback that will be triggered when the system is disposed
  16771. */
  16772. onDispose: () => void;
  16773. private _particles;
  16774. private _epsilon;
  16775. private _capacity;
  16776. private _stockParticles;
  16777. private _newPartsExcess;
  16778. private _vertexData;
  16779. private _vertexBuffer;
  16780. private _vertexBuffers;
  16781. private _spriteBuffer;
  16782. private _indexBuffer;
  16783. private _effect;
  16784. private _customEffect;
  16785. private _cachedDefines;
  16786. private _scaledColorStep;
  16787. private _colorDiff;
  16788. private _scaledDirection;
  16789. private _scaledGravity;
  16790. private _currentRenderId;
  16791. private _alive;
  16792. private _useInstancing;
  16793. private _started;
  16794. private _stopped;
  16795. private _actualFrame;
  16796. private _scaledUpdateSpeed;
  16797. private _vertexBufferSize;
  16798. /** @hidden */
  16799. _currentEmitRateGradient: Nullable<FactorGradient>;
  16800. /** @hidden */
  16801. _currentEmitRate1: number;
  16802. /** @hidden */
  16803. _currentEmitRate2: number;
  16804. /** @hidden */
  16805. _currentStartSizeGradient: Nullable<FactorGradient>;
  16806. /** @hidden */
  16807. _currentStartSize1: number;
  16808. /** @hidden */
  16809. _currentStartSize2: number;
  16810. private readonly _rawTextureWidth;
  16811. private _rampGradientsTexture;
  16812. private _useRampGradients;
  16813. /** Gets or sets a boolean indicating that ramp gradients must be used
  16814. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16815. */
  16816. useRampGradients: boolean;
  16817. /**
  16818. * 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.
  16819. * 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: [])
  16820. */
  16821. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16822. private _subEmitters;
  16823. /**
  16824. * @hidden
  16825. * If the particle systems emitter should be disposed when the particle system is disposed
  16826. */
  16827. _disposeEmitterOnDispose: boolean;
  16828. /**
  16829. * The current active Sub-systems, this property is used by the root particle system only.
  16830. */
  16831. activeSubSystems: Array<ParticleSystem>;
  16832. private _rootParticleSystem;
  16833. /**
  16834. * Gets the current list of active particles
  16835. */
  16836. readonly particles: Particle[];
  16837. /**
  16838. * Returns the string "ParticleSystem"
  16839. * @returns a string containing the class name
  16840. */
  16841. getClassName(): string;
  16842. /**
  16843. * Instantiates a particle system.
  16844. * 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.
  16845. * @param name The name of the particle system
  16846. * @param capacity The max number of particles alive at the same time
  16847. * @param scene The scene the particle system belongs to
  16848. * @param customEffect a custom effect used to change the way particles are rendered by default
  16849. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16850. * @param epsilon Offset used to render the particles
  16851. */
  16852. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16853. private _addFactorGradient;
  16854. private _removeFactorGradient;
  16855. /**
  16856. * Adds a new life time gradient
  16857. * @param gradient defines the gradient to use (between 0 and 1)
  16858. * @param factor defines the life time factor to affect to the specified gradient
  16859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16860. * @returns the current particle system
  16861. */
  16862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16863. /**
  16864. * Remove a specific life time gradient
  16865. * @param gradient defines the gradient to remove
  16866. * @returns the current particle system
  16867. */
  16868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16869. /**
  16870. * Adds a new size gradient
  16871. * @param gradient defines the gradient to use (between 0 and 1)
  16872. * @param factor defines the size factor to affect to the specified gradient
  16873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16874. * @returns the current particle system
  16875. */
  16876. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16877. /**
  16878. * Remove a specific size gradient
  16879. * @param gradient defines the gradient to remove
  16880. * @returns the current particle system
  16881. */
  16882. removeSizeGradient(gradient: number): IParticleSystem;
  16883. /**
  16884. * Adds a new color remap gradient
  16885. * @param gradient defines the gradient to use (between 0 and 1)
  16886. * @param min defines the color remap minimal range
  16887. * @param max defines the color remap maximal range
  16888. * @returns the current particle system
  16889. */
  16890. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16891. /**
  16892. * Remove a specific color remap gradient
  16893. * @param gradient defines the gradient to remove
  16894. * @returns the current particle system
  16895. */
  16896. removeColorRemapGradient(gradient: number): IParticleSystem;
  16897. /**
  16898. * Adds a new alpha remap gradient
  16899. * @param gradient defines the gradient to use (between 0 and 1)
  16900. * @param min defines the alpha remap minimal range
  16901. * @param max defines the alpha remap maximal range
  16902. * @returns the current particle system
  16903. */
  16904. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16905. /**
  16906. * Remove a specific alpha remap gradient
  16907. * @param gradient defines the gradient to remove
  16908. * @returns the current particle system
  16909. */
  16910. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16911. /**
  16912. * Adds a new angular speed gradient
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the angular speed to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific angular speed gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Adds a new velocity gradient
  16927. * @param gradient defines the gradient to use (between 0 and 1)
  16928. * @param factor defines the velocity to affect to the specified gradient
  16929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16930. * @returns the current particle system
  16931. */
  16932. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16933. /**
  16934. * Remove a specific velocity gradient
  16935. * @param gradient defines the gradient to remove
  16936. * @returns the current particle system
  16937. */
  16938. removeVelocityGradient(gradient: number): IParticleSystem;
  16939. /**
  16940. * Adds a new limit velocity gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param factor defines the limit velocity value to affect to the specified gradient
  16943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16944. * @returns the current particle system
  16945. */
  16946. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific limit velocity gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Adds a new drag gradient
  16955. * @param gradient defines the gradient to use (between 0 and 1)
  16956. * @param factor defines the drag value to affect to the specified gradient
  16957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16958. * @returns the current particle system
  16959. */
  16960. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16961. /**
  16962. * Remove a specific drag gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeDragGradient(gradient: number): IParticleSystem;
  16967. /**
  16968. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the emit rate value to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific emit rate gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeEmitRateGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16983. * @param gradient defines the gradient to use (between 0 and 1)
  16984. * @param factor defines the start size value to affect to the specified gradient
  16985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16986. * @returns the current particle system
  16987. */
  16988. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16989. /**
  16990. * Remove a specific start size gradient
  16991. * @param gradient defines the gradient to remove
  16992. * @returns the current particle system
  16993. */
  16994. removeStartSizeGradient(gradient: number): IParticleSystem;
  16995. private _createRampGradientTexture;
  16996. /**
  16997. * Gets the current list of ramp gradients.
  16998. * You must use addRampGradient and removeRampGradient to udpate this list
  16999. * @returns the list of ramp gradients
  17000. */
  17001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17002. /**
  17003. * Adds a new ramp gradient used to remap particle colors
  17004. * @param gradient defines the gradient to use (between 0 and 1)
  17005. * @param color defines the color to affect to the specified gradient
  17006. * @returns the current particle system
  17007. */
  17008. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17009. /**
  17010. * Remove a specific ramp gradient
  17011. * @param gradient defines the gradient to remove
  17012. * @returns the current particle system
  17013. */
  17014. removeRampGradient(gradient: number): ParticleSystem;
  17015. /**
  17016. * Adds a new color gradient
  17017. * @param gradient defines the gradient to use (between 0 and 1)
  17018. * @param color1 defines the color to affect to the specified gradient
  17019. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17020. * @returns this particle system
  17021. */
  17022. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17023. /**
  17024. * Remove a specific color gradient
  17025. * @param gradient defines the gradient to remove
  17026. * @returns this particle system
  17027. */
  17028. removeColorGradient(gradient: number): IParticleSystem;
  17029. private _fetchR;
  17030. protected _reset(): void;
  17031. private _resetEffect;
  17032. private _createVertexBuffers;
  17033. private _createIndexBuffer;
  17034. /**
  17035. * Gets the maximum number of particles active at the same time.
  17036. * @returns The max number of active particles.
  17037. */
  17038. getCapacity(): number;
  17039. /**
  17040. * Gets whether there are still active particles in the system.
  17041. * @returns True if it is alive, otherwise false.
  17042. */
  17043. isAlive(): boolean;
  17044. /**
  17045. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17046. * @returns True if it has been started, otherwise false.
  17047. */
  17048. isStarted(): boolean;
  17049. private _prepareSubEmitterInternalArray;
  17050. /**
  17051. * Starts the particle system and begins to emit
  17052. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17053. */
  17054. start(delay?: number): void;
  17055. /**
  17056. * Stops the particle system.
  17057. * @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.
  17058. */
  17059. stop(stopSubEmitters?: boolean): void;
  17060. /**
  17061. * Remove all active particles
  17062. */
  17063. reset(): void;
  17064. /**
  17065. * @hidden (for internal use only)
  17066. */
  17067. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17068. /**
  17069. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17070. * Its lifetime will start back at 0.
  17071. */
  17072. recycleParticle: (particle: Particle) => void;
  17073. private _stopSubEmitters;
  17074. private _createParticle;
  17075. private _removeFromRoot;
  17076. private _emitFromParticle;
  17077. private _update;
  17078. /** @hidden */
  17079. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17080. /** @hidden */
  17081. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17082. /** @hidden */
  17083. private _getEffect;
  17084. /**
  17085. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17086. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17087. */
  17088. animate(preWarmOnly?: boolean): void;
  17089. private _appendParticleVertices;
  17090. /**
  17091. * Rebuilds the particle system.
  17092. */
  17093. rebuild(): void;
  17094. /**
  17095. * Is this system ready to be used/rendered
  17096. * @return true if the system is ready
  17097. */
  17098. isReady(): boolean;
  17099. private _render;
  17100. /**
  17101. * Renders the particle system in its current state.
  17102. * @returns the current number of particles
  17103. */
  17104. render(): number;
  17105. /**
  17106. * Disposes the particle system and free the associated resources
  17107. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17108. */
  17109. dispose(disposeTexture?: boolean): void;
  17110. /**
  17111. * Clones the particle system.
  17112. * @param name The name of the cloned object
  17113. * @param newEmitter The new emitter to use
  17114. * @returns the cloned particle system
  17115. */
  17116. clone(name: string, newEmitter: any): ParticleSystem;
  17117. /**
  17118. * Serializes the particle system to a JSON object.
  17119. * @returns the JSON object
  17120. */
  17121. serialize(): any;
  17122. /** @hidden */
  17123. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17124. /** @hidden */
  17125. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17126. /**
  17127. * Parses a JSON object to create a particle system.
  17128. * @param parsedParticleSystem The JSON object to parse
  17129. * @param scene The scene to create the particle system in
  17130. * @param rootUrl The root url to use to load external dependencies like texture
  17131. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17132. * @returns the Parsed particle system
  17133. */
  17134. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17135. }
  17136. }
  17137. declare module BABYLON {
  17138. /**
  17139. * A particle represents one of the element emitted by a particle system.
  17140. * This is mainly define by its coordinates, direction, velocity and age.
  17141. */
  17142. export class Particle {
  17143. /**
  17144. * The particle system the particle belongs to.
  17145. */
  17146. particleSystem: ParticleSystem;
  17147. private static _Count;
  17148. /**
  17149. * Unique ID of the particle
  17150. */
  17151. id: number;
  17152. /**
  17153. * The world position of the particle in the scene.
  17154. */
  17155. position: Vector3;
  17156. /**
  17157. * The world direction of the particle in the scene.
  17158. */
  17159. direction: Vector3;
  17160. /**
  17161. * The color of the particle.
  17162. */
  17163. color: Color4;
  17164. /**
  17165. * The color change of the particle per step.
  17166. */
  17167. colorStep: Color4;
  17168. /**
  17169. * Defines how long will the life of the particle be.
  17170. */
  17171. lifeTime: number;
  17172. /**
  17173. * The current age of the particle.
  17174. */
  17175. age: number;
  17176. /**
  17177. * The current size of the particle.
  17178. */
  17179. size: number;
  17180. /**
  17181. * The current scale of the particle.
  17182. */
  17183. scale: Vector2;
  17184. /**
  17185. * The current angle of the particle.
  17186. */
  17187. angle: number;
  17188. /**
  17189. * Defines how fast is the angle changing.
  17190. */
  17191. angularSpeed: number;
  17192. /**
  17193. * Defines the cell index used by the particle to be rendered from a sprite.
  17194. */
  17195. cellIndex: number;
  17196. /**
  17197. * The information required to support color remapping
  17198. */
  17199. remapData: Vector4;
  17200. /** @hidden */
  17201. _randomCellOffset?: number;
  17202. /** @hidden */
  17203. _initialDirection: Nullable<Vector3>;
  17204. /** @hidden */
  17205. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17206. /** @hidden */
  17207. _initialStartSpriteCellID: number;
  17208. /** @hidden */
  17209. _initialEndSpriteCellID: number;
  17210. /** @hidden */
  17211. _currentColorGradient: Nullable<ColorGradient>;
  17212. /** @hidden */
  17213. _currentColor1: Color4;
  17214. /** @hidden */
  17215. _currentColor2: Color4;
  17216. /** @hidden */
  17217. _currentSizeGradient: Nullable<FactorGradient>;
  17218. /** @hidden */
  17219. _currentSize1: number;
  17220. /** @hidden */
  17221. _currentSize2: number;
  17222. /** @hidden */
  17223. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17224. /** @hidden */
  17225. _currentAngularSpeed1: number;
  17226. /** @hidden */
  17227. _currentAngularSpeed2: number;
  17228. /** @hidden */
  17229. _currentVelocityGradient: Nullable<FactorGradient>;
  17230. /** @hidden */
  17231. _currentVelocity1: number;
  17232. /** @hidden */
  17233. _currentVelocity2: number;
  17234. /** @hidden */
  17235. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17236. /** @hidden */
  17237. _currentLimitVelocity1: number;
  17238. /** @hidden */
  17239. _currentLimitVelocity2: number;
  17240. /** @hidden */
  17241. _currentDragGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentDrag1: number;
  17244. /** @hidden */
  17245. _currentDrag2: number;
  17246. /** @hidden */
  17247. _randomNoiseCoordinates1: Vector3;
  17248. /** @hidden */
  17249. _randomNoiseCoordinates2: Vector3;
  17250. /**
  17251. * Creates a new instance Particle
  17252. * @param particleSystem the particle system the particle belongs to
  17253. */
  17254. constructor(
  17255. /**
  17256. * The particle system the particle belongs to.
  17257. */
  17258. particleSystem: ParticleSystem);
  17259. private updateCellInfoFromSystem;
  17260. /**
  17261. * Defines how the sprite cell index is updated for the particle
  17262. */
  17263. updateCellIndex(): void;
  17264. /** @hidden */
  17265. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17266. /** @hidden */
  17267. _inheritParticleInfoToSubEmitters(): void;
  17268. /** @hidden */
  17269. _reset(): void;
  17270. /**
  17271. * Copy the properties of particle to another one.
  17272. * @param other the particle to copy the information to.
  17273. */
  17274. copyTo(other: Particle): void;
  17275. }
  17276. }
  17277. declare module BABYLON {
  17278. /**
  17279. * Particle emitter represents a volume emitting particles.
  17280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17281. */
  17282. export interface IParticleEmitterType {
  17283. /**
  17284. * Called by the particle System when the direction is computed for the created particle.
  17285. * @param worldMatrix is the world matrix of the particle system
  17286. * @param directionToUpdate is the direction vector to update with the result
  17287. * @param particle is the particle we are computed the direction for
  17288. */
  17289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17290. /**
  17291. * Called by the particle System when the position is computed for the created particle.
  17292. * @param worldMatrix is the world matrix of the particle system
  17293. * @param positionToUpdate is the position vector to update with the result
  17294. * @param particle is the particle we are computed the position for
  17295. */
  17296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17297. /**
  17298. * Clones the current emitter and returns a copy of it
  17299. * @returns the new emitter
  17300. */
  17301. clone(): IParticleEmitterType;
  17302. /**
  17303. * Called by the GPUParticleSystem to setup the update shader
  17304. * @param effect defines the update shader
  17305. */
  17306. applyToShader(effect: Effect): void;
  17307. /**
  17308. * Returns a string to use to update the GPU particles update shader
  17309. * @returns the effect defines string
  17310. */
  17311. getEffectDefines(): string;
  17312. /**
  17313. * Returns a string representing the class name
  17314. * @returns a string containing the class name
  17315. */
  17316. getClassName(): string;
  17317. /**
  17318. * Serializes the particle system to a JSON object.
  17319. * @returns the JSON object
  17320. */
  17321. serialize(): any;
  17322. /**
  17323. * Parse properties from a JSON object
  17324. * @param serializationObject defines the JSON object
  17325. */
  17326. parse(serializationObject: any): void;
  17327. }
  17328. }
  17329. declare module BABYLON {
  17330. /**
  17331. * Particle emitter emitting particles from the inside of a box.
  17332. * It emits the particles randomly between 2 given directions.
  17333. */
  17334. export class BoxParticleEmitter implements IParticleEmitterType {
  17335. /**
  17336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17337. */
  17338. direction1: Vector3;
  17339. /**
  17340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17341. */
  17342. direction2: Vector3;
  17343. /**
  17344. * 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.
  17345. */
  17346. minEmitBox: Vector3;
  17347. /**
  17348. * 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.
  17349. */
  17350. maxEmitBox: Vector3;
  17351. /**
  17352. * Creates a new instance BoxParticleEmitter
  17353. */
  17354. constructor();
  17355. /**
  17356. * Called by the particle System when the direction is computed for the created particle.
  17357. * @param worldMatrix is the world matrix of the particle system
  17358. * @param directionToUpdate is the direction vector to update with the result
  17359. * @param particle is the particle we are computed the direction for
  17360. */
  17361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17362. /**
  17363. * Called by the particle System when the position is computed for the created particle.
  17364. * @param worldMatrix is the world matrix of the particle system
  17365. * @param positionToUpdate is the position vector to update with the result
  17366. * @param particle is the particle we are computed the position for
  17367. */
  17368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17369. /**
  17370. * Clones the current emitter and returns a copy of it
  17371. * @returns the new emitter
  17372. */
  17373. clone(): BoxParticleEmitter;
  17374. /**
  17375. * Called by the GPUParticleSystem to setup the update shader
  17376. * @param effect defines the update shader
  17377. */
  17378. applyToShader(effect: Effect): void;
  17379. /**
  17380. * Returns a string to use to update the GPU particles update shader
  17381. * @returns a string containng the defines string
  17382. */
  17383. getEffectDefines(): string;
  17384. /**
  17385. * Returns the string "BoxParticleEmitter"
  17386. * @returns a string containing the class name
  17387. */
  17388. getClassName(): string;
  17389. /**
  17390. * Serializes the particle system to a JSON object.
  17391. * @returns the JSON object
  17392. */
  17393. serialize(): any;
  17394. /**
  17395. * Parse properties from a JSON object
  17396. * @param serializationObject defines the JSON object
  17397. */
  17398. parse(serializationObject: any): void;
  17399. }
  17400. }
  17401. declare module BABYLON {
  17402. /**
  17403. * Particle emitter emitting particles from the inside of a cone.
  17404. * It emits the particles alongside the cone volume from the base to the particle.
  17405. * The emission direction might be randomized.
  17406. */
  17407. export class ConeParticleEmitter implements IParticleEmitterType {
  17408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17409. directionRandomizer: number;
  17410. private _radius;
  17411. private _angle;
  17412. private _height;
  17413. /**
  17414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17415. */
  17416. radiusRange: number;
  17417. /**
  17418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17419. */
  17420. heightRange: number;
  17421. /**
  17422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17423. */
  17424. emitFromSpawnPointOnly: boolean;
  17425. /**
  17426. * Gets or sets the radius of the emission cone
  17427. */
  17428. radius: number;
  17429. /**
  17430. * Gets or sets the angle of the emission cone
  17431. */
  17432. angle: number;
  17433. private _buildHeight;
  17434. /**
  17435. * Creates a new instance ConeParticleEmitter
  17436. * @param radius the radius of the emission cone (1 by default)
  17437. * @param angle the cone base angle (PI by default)
  17438. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17439. */
  17440. constructor(radius?: number, angle?: number,
  17441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17442. directionRandomizer?: number);
  17443. /**
  17444. * Called by the particle System when the direction is computed for the created particle.
  17445. * @param worldMatrix is the world matrix of the particle system
  17446. * @param directionToUpdate is the direction vector to update with the result
  17447. * @param particle is the particle we are computed the direction for
  17448. */
  17449. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17450. /**
  17451. * Called by the particle System when the position is computed for the created particle.
  17452. * @param worldMatrix is the world matrix of the particle system
  17453. * @param positionToUpdate is the position vector to update with the result
  17454. * @param particle is the particle we are computed the position for
  17455. */
  17456. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17457. /**
  17458. * Clones the current emitter and returns a copy of it
  17459. * @returns the new emitter
  17460. */
  17461. clone(): ConeParticleEmitter;
  17462. /**
  17463. * Called by the GPUParticleSystem to setup the update shader
  17464. * @param effect defines the update shader
  17465. */
  17466. applyToShader(effect: Effect): void;
  17467. /**
  17468. * Returns a string to use to update the GPU particles update shader
  17469. * @returns a string containng the defines string
  17470. */
  17471. getEffectDefines(): string;
  17472. /**
  17473. * Returns the string "ConeParticleEmitter"
  17474. * @returns a string containing the class name
  17475. */
  17476. getClassName(): string;
  17477. /**
  17478. * Serializes the particle system to a JSON object.
  17479. * @returns the JSON object
  17480. */
  17481. serialize(): any;
  17482. /**
  17483. * Parse properties from a JSON object
  17484. * @param serializationObject defines the JSON object
  17485. */
  17486. parse(serializationObject: any): void;
  17487. }
  17488. }
  17489. declare module BABYLON {
  17490. /**
  17491. * Particle emitter emitting particles from the inside of a cylinder.
  17492. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17493. */
  17494. export class CylinderParticleEmitter implements IParticleEmitterType {
  17495. /**
  17496. * The radius of the emission cylinder.
  17497. */
  17498. radius: number;
  17499. /**
  17500. * The height of the emission cylinder.
  17501. */
  17502. height: number;
  17503. /**
  17504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17505. */
  17506. radiusRange: number;
  17507. /**
  17508. * How much to randomize the particle direction [0-1].
  17509. */
  17510. directionRandomizer: number;
  17511. /**
  17512. * Creates a new instance CylinderParticleEmitter
  17513. * @param radius the radius of the emission cylinder (1 by default)
  17514. * @param height the height of the emission cylinder (1 by default)
  17515. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17516. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17517. */
  17518. constructor(
  17519. /**
  17520. * The radius of the emission cylinder.
  17521. */
  17522. radius?: number,
  17523. /**
  17524. * The height of the emission cylinder.
  17525. */
  17526. height?: number,
  17527. /**
  17528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17529. */
  17530. radiusRange?: number,
  17531. /**
  17532. * How much to randomize the particle direction [0-1].
  17533. */
  17534. directionRandomizer?: number);
  17535. /**
  17536. * Called by the particle System when the direction is computed for the created particle.
  17537. * @param worldMatrix is the world matrix of the particle system
  17538. * @param directionToUpdate is the direction vector to update with the result
  17539. * @param particle is the particle we are computed the direction for
  17540. */
  17541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17542. /**
  17543. * Called by the particle System when the position is computed for the created particle.
  17544. * @param worldMatrix is the world matrix of the particle system
  17545. * @param positionToUpdate is the position vector to update with the result
  17546. * @param particle is the particle we are computed the position for
  17547. */
  17548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17549. /**
  17550. * Clones the current emitter and returns a copy of it
  17551. * @returns the new emitter
  17552. */
  17553. clone(): CylinderParticleEmitter;
  17554. /**
  17555. * Called by the GPUParticleSystem to setup the update shader
  17556. * @param effect defines the update shader
  17557. */
  17558. applyToShader(effect: Effect): void;
  17559. /**
  17560. * Returns a string to use to update the GPU particles update shader
  17561. * @returns a string containng the defines string
  17562. */
  17563. getEffectDefines(): string;
  17564. /**
  17565. * Returns the string "CylinderParticleEmitter"
  17566. * @returns a string containing the class name
  17567. */
  17568. getClassName(): string;
  17569. /**
  17570. * Serializes the particle system to a JSON object.
  17571. * @returns the JSON object
  17572. */
  17573. serialize(): any;
  17574. /**
  17575. * Parse properties from a JSON object
  17576. * @param serializationObject defines the JSON object
  17577. */
  17578. parse(serializationObject: any): void;
  17579. }
  17580. /**
  17581. * Particle emitter emitting particles from the inside of a cylinder.
  17582. * It emits the particles randomly between two vectors.
  17583. */
  17584. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17585. /**
  17586. * The min limit of the emission direction.
  17587. */
  17588. direction1: Vector3;
  17589. /**
  17590. * The max limit of the emission direction.
  17591. */
  17592. direction2: Vector3;
  17593. /**
  17594. * Creates a new instance CylinderDirectedParticleEmitter
  17595. * @param radius the radius of the emission cylinder (1 by default)
  17596. * @param height the height of the emission cylinder (1 by default)
  17597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17598. * @param direction1 the min limit of the emission direction (up vector by default)
  17599. * @param direction2 the max limit of the emission direction (up vector by default)
  17600. */
  17601. constructor(radius?: number, height?: number, radiusRange?: number,
  17602. /**
  17603. * The min limit of the emission direction.
  17604. */
  17605. direction1?: Vector3,
  17606. /**
  17607. * The max limit of the emission direction.
  17608. */
  17609. direction2?: Vector3);
  17610. /**
  17611. * Called by the particle System when the direction is computed for the created particle.
  17612. * @param worldMatrix is the world matrix of the particle system
  17613. * @param directionToUpdate is the direction vector to update with the result
  17614. * @param particle is the particle we are computed the direction for
  17615. */
  17616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17617. /**
  17618. * Clones the current emitter and returns a copy of it
  17619. * @returns the new emitter
  17620. */
  17621. clone(): CylinderDirectedParticleEmitter;
  17622. /**
  17623. * Called by the GPUParticleSystem to setup the update shader
  17624. * @param effect defines the update shader
  17625. */
  17626. applyToShader(effect: Effect): void;
  17627. /**
  17628. * Returns a string to use to update the GPU particles update shader
  17629. * @returns a string containng the defines string
  17630. */
  17631. getEffectDefines(): string;
  17632. /**
  17633. * Returns the string "CylinderDirectedParticleEmitter"
  17634. * @returns a string containing the class name
  17635. */
  17636. getClassName(): string;
  17637. /**
  17638. * Serializes the particle system to a JSON object.
  17639. * @returns the JSON object
  17640. */
  17641. serialize(): any;
  17642. /**
  17643. * Parse properties from a JSON object
  17644. * @param serializationObject defines the JSON object
  17645. */
  17646. parse(serializationObject: any): void;
  17647. }
  17648. }
  17649. declare module BABYLON {
  17650. /**
  17651. * Particle emitter emitting particles from the inside of a hemisphere.
  17652. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17653. */
  17654. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17655. /**
  17656. * The radius of the emission hemisphere.
  17657. */
  17658. radius: number;
  17659. /**
  17660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17661. */
  17662. radiusRange: number;
  17663. /**
  17664. * How much to randomize the particle direction [0-1].
  17665. */
  17666. directionRandomizer: number;
  17667. /**
  17668. * Creates a new instance HemisphericParticleEmitter
  17669. * @param radius the radius of the emission hemisphere (1 by default)
  17670. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17671. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17672. */
  17673. constructor(
  17674. /**
  17675. * The radius of the emission hemisphere.
  17676. */
  17677. radius?: number,
  17678. /**
  17679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17680. */
  17681. radiusRange?: number,
  17682. /**
  17683. * How much to randomize the particle direction [0-1].
  17684. */
  17685. directionRandomizer?: number);
  17686. /**
  17687. * Called by the particle System when the direction is computed for the created particle.
  17688. * @param worldMatrix is the world matrix of the particle system
  17689. * @param directionToUpdate is the direction vector to update with the result
  17690. * @param particle is the particle we are computed the direction for
  17691. */
  17692. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17693. /**
  17694. * Called by the particle System when the position is computed for the created particle.
  17695. * @param worldMatrix is the world matrix of the particle system
  17696. * @param positionToUpdate is the position vector to update with the result
  17697. * @param particle is the particle we are computed the position for
  17698. */
  17699. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17700. /**
  17701. * Clones the current emitter and returns a copy of it
  17702. * @returns the new emitter
  17703. */
  17704. clone(): HemisphericParticleEmitter;
  17705. /**
  17706. * Called by the GPUParticleSystem to setup the update shader
  17707. * @param effect defines the update shader
  17708. */
  17709. applyToShader(effect: Effect): void;
  17710. /**
  17711. * Returns a string to use to update the GPU particles update shader
  17712. * @returns a string containng the defines string
  17713. */
  17714. getEffectDefines(): string;
  17715. /**
  17716. * Returns the string "HemisphericParticleEmitter"
  17717. * @returns a string containing the class name
  17718. */
  17719. getClassName(): string;
  17720. /**
  17721. * Serializes the particle system to a JSON object.
  17722. * @returns the JSON object
  17723. */
  17724. serialize(): any;
  17725. /**
  17726. * Parse properties from a JSON object
  17727. * @param serializationObject defines the JSON object
  17728. */
  17729. parse(serializationObject: any): void;
  17730. }
  17731. }
  17732. declare module BABYLON {
  17733. /**
  17734. * Particle emitter emitting particles from a point.
  17735. * It emits the particles randomly between 2 given directions.
  17736. */
  17737. export class PointParticleEmitter implements IParticleEmitterType {
  17738. /**
  17739. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17740. */
  17741. direction1: Vector3;
  17742. /**
  17743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17744. */
  17745. direction2: Vector3;
  17746. /**
  17747. * Creates a new instance PointParticleEmitter
  17748. */
  17749. constructor();
  17750. /**
  17751. * Called by the particle System when the direction is computed for the created particle.
  17752. * @param worldMatrix is the world matrix of the particle system
  17753. * @param directionToUpdate is the direction vector to update with the result
  17754. * @param particle is the particle we are computed the direction for
  17755. */
  17756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17757. /**
  17758. * Called by the particle System when the position is computed for the created particle.
  17759. * @param worldMatrix is the world matrix of the particle system
  17760. * @param positionToUpdate is the position vector to update with the result
  17761. * @param particle is the particle we are computed the position for
  17762. */
  17763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17764. /**
  17765. * Clones the current emitter and returns a copy of it
  17766. * @returns the new emitter
  17767. */
  17768. clone(): PointParticleEmitter;
  17769. /**
  17770. * Called by the GPUParticleSystem to setup the update shader
  17771. * @param effect defines the update shader
  17772. */
  17773. applyToShader(effect: Effect): void;
  17774. /**
  17775. * Returns a string to use to update the GPU particles update shader
  17776. * @returns a string containng the defines string
  17777. */
  17778. getEffectDefines(): string;
  17779. /**
  17780. * Returns the string "PointParticleEmitter"
  17781. * @returns a string containing the class name
  17782. */
  17783. getClassName(): string;
  17784. /**
  17785. * Serializes the particle system to a JSON object.
  17786. * @returns the JSON object
  17787. */
  17788. serialize(): any;
  17789. /**
  17790. * Parse properties from a JSON object
  17791. * @param serializationObject defines the JSON object
  17792. */
  17793. parse(serializationObject: any): void;
  17794. }
  17795. }
  17796. declare module BABYLON {
  17797. /**
  17798. * Particle emitter emitting particles from the inside of a sphere.
  17799. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17800. */
  17801. export class SphereParticleEmitter implements IParticleEmitterType {
  17802. /**
  17803. * The radius of the emission sphere.
  17804. */
  17805. radius: number;
  17806. /**
  17807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17808. */
  17809. radiusRange: number;
  17810. /**
  17811. * How much to randomize the particle direction [0-1].
  17812. */
  17813. directionRandomizer: number;
  17814. /**
  17815. * Creates a new instance SphereParticleEmitter
  17816. * @param radius the radius of the emission sphere (1 by default)
  17817. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17819. */
  17820. constructor(
  17821. /**
  17822. * The radius of the emission sphere.
  17823. */
  17824. radius?: number,
  17825. /**
  17826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17827. */
  17828. radiusRange?: number,
  17829. /**
  17830. * How much to randomize the particle direction [0-1].
  17831. */
  17832. directionRandomizer?: number);
  17833. /**
  17834. * Called by the particle System when the direction is computed for the created particle.
  17835. * @param worldMatrix is the world matrix of the particle system
  17836. * @param directionToUpdate is the direction vector to update with the result
  17837. * @param particle is the particle we are computed the direction for
  17838. */
  17839. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17840. /**
  17841. * Called by the particle System when the position is computed for the created particle.
  17842. * @param worldMatrix is the world matrix of the particle system
  17843. * @param positionToUpdate is the position vector to update with the result
  17844. * @param particle is the particle we are computed the position for
  17845. */
  17846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17847. /**
  17848. * Clones the current emitter and returns a copy of it
  17849. * @returns the new emitter
  17850. */
  17851. clone(): SphereParticleEmitter;
  17852. /**
  17853. * Called by the GPUParticleSystem to setup the update shader
  17854. * @param effect defines the update shader
  17855. */
  17856. applyToShader(effect: Effect): void;
  17857. /**
  17858. * Returns a string to use to update the GPU particles update shader
  17859. * @returns a string containng the defines string
  17860. */
  17861. getEffectDefines(): string;
  17862. /**
  17863. * Returns the string "SphereParticleEmitter"
  17864. * @returns a string containing the class name
  17865. */
  17866. getClassName(): string;
  17867. /**
  17868. * Serializes the particle system to a JSON object.
  17869. * @returns the JSON object
  17870. */
  17871. serialize(): any;
  17872. /**
  17873. * Parse properties from a JSON object
  17874. * @param serializationObject defines the JSON object
  17875. */
  17876. parse(serializationObject: any): void;
  17877. }
  17878. /**
  17879. * Particle emitter emitting particles from the inside of a sphere.
  17880. * It emits the particles randomly between two vectors.
  17881. */
  17882. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17883. /**
  17884. * The min limit of the emission direction.
  17885. */
  17886. direction1: Vector3;
  17887. /**
  17888. * The max limit of the emission direction.
  17889. */
  17890. direction2: Vector3;
  17891. /**
  17892. * Creates a new instance SphereDirectedParticleEmitter
  17893. * @param radius the radius of the emission sphere (1 by default)
  17894. * @param direction1 the min limit of the emission direction (up vector by default)
  17895. * @param direction2 the max limit of the emission direction (up vector by default)
  17896. */
  17897. constructor(radius?: number,
  17898. /**
  17899. * The min limit of the emission direction.
  17900. */
  17901. direction1?: Vector3,
  17902. /**
  17903. * The max limit of the emission direction.
  17904. */
  17905. direction2?: Vector3);
  17906. /**
  17907. * Called by the particle System when the direction is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param directionToUpdate is the direction vector to update with the result
  17910. * @param particle is the particle we are computed the direction for
  17911. */
  17912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): SphereDirectedParticleEmitter;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns a string containng the defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns the string "SphereDirectedParticleEmitter"
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module BABYLON {
  17946. /**
  17947. * Interface representing a particle system in Babylon.js.
  17948. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17949. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17950. */
  17951. export interface IParticleSystem {
  17952. /**
  17953. * List of animations used by the particle system.
  17954. */
  17955. animations: Animation[];
  17956. /**
  17957. * The id of the Particle system.
  17958. */
  17959. id: string;
  17960. /**
  17961. * The name of the Particle system.
  17962. */
  17963. name: string;
  17964. /**
  17965. * The emitter represents the Mesh or position we are attaching the particle system to.
  17966. */
  17967. emitter: Nullable<AbstractMesh | Vector3>;
  17968. /**
  17969. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17970. */
  17971. isBillboardBased: boolean;
  17972. /**
  17973. * The rendering group used by the Particle system to chose when to render.
  17974. */
  17975. renderingGroupId: number;
  17976. /**
  17977. * The layer mask we are rendering the particles through.
  17978. */
  17979. layerMask: number;
  17980. /**
  17981. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17982. */
  17983. updateSpeed: number;
  17984. /**
  17985. * The amount of time the particle system is running (depends of the overall update speed).
  17986. */
  17987. targetStopDuration: number;
  17988. /**
  17989. * The texture used to render each particle. (this can be a spritesheet)
  17990. */
  17991. particleTexture: Nullable<Texture>;
  17992. /**
  17993. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17994. */
  17995. blendMode: number;
  17996. /**
  17997. * Minimum life time of emitting particles.
  17998. */
  17999. minLifeTime: number;
  18000. /**
  18001. * Maximum life time of emitting particles.
  18002. */
  18003. maxLifeTime: number;
  18004. /**
  18005. * Minimum Size of emitting particles.
  18006. */
  18007. minSize: number;
  18008. /**
  18009. * Maximum Size of emitting particles.
  18010. */
  18011. maxSize: number;
  18012. /**
  18013. * Minimum scale of emitting particles on X axis.
  18014. */
  18015. minScaleX: number;
  18016. /**
  18017. * Maximum scale of emitting particles on X axis.
  18018. */
  18019. maxScaleX: number;
  18020. /**
  18021. * Minimum scale of emitting particles on Y axis.
  18022. */
  18023. minScaleY: number;
  18024. /**
  18025. * Maximum scale of emitting particles on Y axis.
  18026. */
  18027. maxScaleY: number;
  18028. /**
  18029. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18030. */
  18031. color1: Color4;
  18032. /**
  18033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18034. */
  18035. color2: Color4;
  18036. /**
  18037. * Color the particle will have at the end of its lifetime.
  18038. */
  18039. colorDead: Color4;
  18040. /**
  18041. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18042. */
  18043. emitRate: number;
  18044. /**
  18045. * You can use gravity if you want to give an orientation to your particles.
  18046. */
  18047. gravity: Vector3;
  18048. /**
  18049. * Minimum power of emitting particles.
  18050. */
  18051. minEmitPower: number;
  18052. /**
  18053. * Maximum power of emitting particles.
  18054. */
  18055. maxEmitPower: number;
  18056. /**
  18057. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18058. */
  18059. minAngularSpeed: number;
  18060. /**
  18061. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18062. */
  18063. maxAngularSpeed: number;
  18064. /**
  18065. * Gets or sets the minimal initial rotation in radians.
  18066. */
  18067. minInitialRotation: number;
  18068. /**
  18069. * Gets or sets the maximal initial rotation in radians.
  18070. */
  18071. maxInitialRotation: number;
  18072. /**
  18073. * The particle emitter type defines the emitter used by the particle system.
  18074. * It can be for example box, sphere, or cone...
  18075. */
  18076. particleEmitterType: Nullable<IParticleEmitterType>;
  18077. /**
  18078. * Defines the delay in milliseconds before starting the system (0 by default)
  18079. */
  18080. startDelay: number;
  18081. /**
  18082. * 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
  18083. */
  18084. preWarmCycles: number;
  18085. /**
  18086. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18087. */
  18088. preWarmStepOffset: number;
  18089. /**
  18090. * 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)
  18091. */
  18092. spriteCellChangeSpeed: number;
  18093. /**
  18094. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18095. */
  18096. startSpriteCellID: number;
  18097. /**
  18098. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18099. */
  18100. endSpriteCellID: number;
  18101. /**
  18102. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18103. */
  18104. spriteCellWidth: number;
  18105. /**
  18106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18107. */
  18108. spriteCellHeight: number;
  18109. /**
  18110. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18111. */
  18112. spriteRandomStartCell: boolean;
  18113. /**
  18114. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18115. */
  18116. isAnimationSheetEnabled: boolean;
  18117. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18118. translationPivot: Vector2;
  18119. /**
  18120. * Gets or sets a texture used to add random noise to particle positions
  18121. */
  18122. noiseTexture: Nullable<BaseTexture>;
  18123. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18124. noiseStrength: Vector3;
  18125. /**
  18126. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18127. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18128. */
  18129. billboardMode: number;
  18130. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18131. limitVelocityDamping: number;
  18132. /**
  18133. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18134. */
  18135. beginAnimationOnStart: boolean;
  18136. /**
  18137. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18138. */
  18139. beginAnimationFrom: number;
  18140. /**
  18141. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18142. */
  18143. beginAnimationTo: number;
  18144. /**
  18145. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18146. */
  18147. beginAnimationLoop: boolean;
  18148. /**
  18149. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18150. */
  18151. disposeOnStop: boolean;
  18152. /**
  18153. * Gets the maximum number of particles active at the same time.
  18154. * @returns The max number of active particles.
  18155. */
  18156. getCapacity(): number;
  18157. /**
  18158. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18159. * @returns True if it has been started, otherwise false.
  18160. */
  18161. isStarted(): boolean;
  18162. /**
  18163. * Animates the particle system for this frame.
  18164. */
  18165. animate(): void;
  18166. /**
  18167. * Renders the particle system in its current state.
  18168. * @returns the current number of particles
  18169. */
  18170. render(): number;
  18171. /**
  18172. * Dispose the particle system and frees its associated resources.
  18173. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18174. */
  18175. dispose(disposeTexture?: boolean): void;
  18176. /**
  18177. * Clones the particle system.
  18178. * @param name The name of the cloned object
  18179. * @param newEmitter The new emitter to use
  18180. * @returns the cloned particle system
  18181. */
  18182. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18183. /**
  18184. * Serializes the particle system to a JSON object.
  18185. * @returns the JSON object
  18186. */
  18187. serialize(): any;
  18188. /**
  18189. * Rebuild the particle system
  18190. */
  18191. rebuild(): void;
  18192. /**
  18193. * Starts the particle system and begins to emit
  18194. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18195. */
  18196. start(delay?: number): void;
  18197. /**
  18198. * Stops the particle system.
  18199. */
  18200. stop(): void;
  18201. /**
  18202. * Remove all active particles
  18203. */
  18204. reset(): void;
  18205. /**
  18206. * Is this system ready to be used/rendered
  18207. * @return true if the system is ready
  18208. */
  18209. isReady(): boolean;
  18210. /**
  18211. * Adds a new color gradient
  18212. * @param gradient defines the gradient to use (between 0 and 1)
  18213. * @param color1 defines the color to affect to the specified gradient
  18214. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18215. * @returns the current particle system
  18216. */
  18217. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18218. /**
  18219. * Remove a specific color gradient
  18220. * @param gradient defines the gradient to remove
  18221. * @returns the current particle system
  18222. */
  18223. removeColorGradient(gradient: number): IParticleSystem;
  18224. /**
  18225. * Adds a new size gradient
  18226. * @param gradient defines the gradient to use (between 0 and 1)
  18227. * @param factor defines the size factor to affect to the specified gradient
  18228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18229. * @returns the current particle system
  18230. */
  18231. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18232. /**
  18233. * Remove a specific size gradient
  18234. * @param gradient defines the gradient to remove
  18235. * @returns the current particle system
  18236. */
  18237. removeSizeGradient(gradient: number): IParticleSystem;
  18238. /**
  18239. * Gets the current list of color gradients.
  18240. * You must use addColorGradient and removeColorGradient to udpate this list
  18241. * @returns the list of color gradients
  18242. */
  18243. getColorGradients(): Nullable<Array<ColorGradient>>;
  18244. /**
  18245. * Gets the current list of size gradients.
  18246. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18247. * @returns the list of size gradients
  18248. */
  18249. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18250. /**
  18251. * Gets the current list of angular speed gradients.
  18252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18253. * @returns the list of angular speed gradients
  18254. */
  18255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18256. /**
  18257. * Adds a new angular speed gradient
  18258. * @param gradient defines the gradient to use (between 0 and 1)
  18259. * @param factor defines the angular speed to affect to the specified gradient
  18260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18261. * @returns the current particle system
  18262. */
  18263. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18264. /**
  18265. * Remove a specific angular speed gradient
  18266. * @param gradient defines the gradient to remove
  18267. * @returns the current particle system
  18268. */
  18269. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18270. /**
  18271. * Gets the current list of velocity gradients.
  18272. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18273. * @returns the list of velocity gradients
  18274. */
  18275. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18276. /**
  18277. * Adds a new velocity gradient
  18278. * @param gradient defines the gradient to use (between 0 and 1)
  18279. * @param factor defines the velocity to affect to the specified gradient
  18280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18281. * @returns the current particle system
  18282. */
  18283. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18284. /**
  18285. * Remove a specific velocity gradient
  18286. * @param gradient defines the gradient to remove
  18287. * @returns the current particle system
  18288. */
  18289. removeVelocityGradient(gradient: number): IParticleSystem;
  18290. /**
  18291. * Gets the current list of limit velocity gradients.
  18292. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18293. * @returns the list of limit velocity gradients
  18294. */
  18295. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18296. /**
  18297. * Adds a new limit velocity gradient
  18298. * @param gradient defines the gradient to use (between 0 and 1)
  18299. * @param factor defines the limit velocity to affect to the specified gradient
  18300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18301. * @returns the current particle system
  18302. */
  18303. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18304. /**
  18305. * Remove a specific limit velocity gradient
  18306. * @param gradient defines the gradient to remove
  18307. * @returns the current particle system
  18308. */
  18309. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18310. /**
  18311. * Adds a new drag gradient
  18312. * @param gradient defines the gradient to use (between 0 and 1)
  18313. * @param factor defines the drag to affect to the specified gradient
  18314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18315. * @returns the current particle system
  18316. */
  18317. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18318. /**
  18319. * Remove a specific drag gradient
  18320. * @param gradient defines the gradient to remove
  18321. * @returns the current particle system
  18322. */
  18323. removeDragGradient(gradient: number): IParticleSystem;
  18324. /**
  18325. * Gets the current list of drag gradients.
  18326. * You must use addDragGradient and removeDragGradient to udpate this list
  18327. * @returns the list of drag gradients
  18328. */
  18329. getDragGradients(): Nullable<Array<FactorGradient>>;
  18330. /**
  18331. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18332. * @param gradient defines the gradient to use (between 0 and 1)
  18333. * @param factor defines the emit rate to affect to the specified gradient
  18334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18335. * @returns the current particle system
  18336. */
  18337. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18338. /**
  18339. * Remove a specific emit rate gradient
  18340. * @param gradient defines the gradient to remove
  18341. * @returns the current particle system
  18342. */
  18343. removeEmitRateGradient(gradient: number): IParticleSystem;
  18344. /**
  18345. * Gets the current list of emit rate gradients.
  18346. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18347. * @returns the list of emit rate gradients
  18348. */
  18349. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18350. /**
  18351. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18352. * @param gradient defines the gradient to use (between 0 and 1)
  18353. * @param factor defines the start size to affect to the specified gradient
  18354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18355. * @returns the current particle system
  18356. */
  18357. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18358. /**
  18359. * Remove a specific start size gradient
  18360. * @param gradient defines the gradient to remove
  18361. * @returns the current particle system
  18362. */
  18363. removeStartSizeGradient(gradient: number): IParticleSystem;
  18364. /**
  18365. * Gets the current list of start size gradients.
  18366. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18367. * @returns the list of start size gradients
  18368. */
  18369. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18370. /**
  18371. * Adds a new life time gradient
  18372. * @param gradient defines the gradient to use (between 0 and 1)
  18373. * @param factor defines the life time factor to affect to the specified gradient
  18374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18375. * @returns the current particle system
  18376. */
  18377. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18378. /**
  18379. * Remove a specific life time gradient
  18380. * @param gradient defines the gradient to remove
  18381. * @returns the current particle system
  18382. */
  18383. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18384. /**
  18385. * Gets the current list of life time gradients.
  18386. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18387. * @returns the list of life time gradients
  18388. */
  18389. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18390. /**
  18391. * Gets the current list of color gradients.
  18392. * You must use addColorGradient and removeColorGradient to udpate this list
  18393. * @returns the list of color gradients
  18394. */
  18395. getColorGradients(): Nullable<Array<ColorGradient>>;
  18396. /**
  18397. * Adds a new ramp gradient used to remap particle colors
  18398. * @param gradient defines the gradient to use (between 0 and 1)
  18399. * @param color defines the color to affect to the specified gradient
  18400. * @returns the current particle system
  18401. */
  18402. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18403. /**
  18404. * Gets the current list of ramp gradients.
  18405. * You must use addRampGradient and removeRampGradient to udpate this list
  18406. * @returns the list of ramp gradients
  18407. */
  18408. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18409. /** Gets or sets a boolean indicating that ramp gradients must be used
  18410. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18411. */
  18412. useRampGradients: boolean;
  18413. /**
  18414. * Adds a new color remap gradient
  18415. * @param gradient defines the gradient to use (between 0 and 1)
  18416. * @param min defines the color remap minimal range
  18417. * @param max defines the color remap maximal range
  18418. * @returns the current particle system
  18419. */
  18420. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18421. /**
  18422. * Gets the current list of color remap gradients.
  18423. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18424. * @returns the list of color remap gradients
  18425. */
  18426. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18427. /**
  18428. * Adds a new alpha remap gradient
  18429. * @param gradient defines the gradient to use (between 0 and 1)
  18430. * @param min defines the alpha remap minimal range
  18431. * @param max defines the alpha remap maximal range
  18432. * @returns the current particle system
  18433. */
  18434. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18435. /**
  18436. * Gets the current list of alpha remap gradients.
  18437. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18438. * @returns the list of alpha remap gradients
  18439. */
  18440. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18441. /**
  18442. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18443. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18444. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18445. * @returns the emitter
  18446. */
  18447. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18448. /**
  18449. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18450. * @param radius The radius of the hemisphere to emit from
  18451. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18452. * @returns the emitter
  18453. */
  18454. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18455. /**
  18456. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18457. * @param radius The radius of the sphere to emit from
  18458. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18459. * @returns the emitter
  18460. */
  18461. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18462. /**
  18463. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18464. * @param radius The radius of the sphere to emit from
  18465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18467. * @returns the emitter
  18468. */
  18469. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18470. /**
  18471. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18472. * @param radius The radius of the emission cylinder
  18473. * @param height The height of the emission cylinder
  18474. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18475. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18476. * @returns the emitter
  18477. */
  18478. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18479. /**
  18480. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18481. * @param radius The radius of the cylinder to emit from
  18482. * @param height The height of the emission cylinder
  18483. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18486. * @returns the emitter
  18487. */
  18488. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18489. /**
  18490. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18491. * @param radius The radius of the cone to emit from
  18492. * @param angle The base angle of the cone
  18493. * @returns the emitter
  18494. */
  18495. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18496. /**
  18497. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18500. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18501. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18502. * @returns the emitter
  18503. */
  18504. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18505. /**
  18506. * Get hosting scene
  18507. * @returns the scene
  18508. */
  18509. getScene(): Scene;
  18510. }
  18511. }
  18512. declare module BABYLON {
  18513. /**
  18514. * Creates an instance based on a source mesh.
  18515. */
  18516. export class InstancedMesh extends AbstractMesh {
  18517. private _sourceMesh;
  18518. private _currentLOD;
  18519. /** @hidden */
  18520. _indexInSourceMeshInstanceArray: number;
  18521. constructor(name: string, source: Mesh);
  18522. /**
  18523. * Returns the string "InstancedMesh".
  18524. */
  18525. getClassName(): string;
  18526. /** Gets the list of lights affecting that mesh */
  18527. readonly lightSources: Light[];
  18528. _resyncLightSources(): void;
  18529. _resyncLighSource(light: Light): void;
  18530. _removeLightSource(light: Light): void;
  18531. /**
  18532. * If the source mesh receives shadows
  18533. */
  18534. readonly receiveShadows: boolean;
  18535. /**
  18536. * The material of the source mesh
  18537. */
  18538. readonly material: Nullable<Material>;
  18539. /**
  18540. * Visibility of the source mesh
  18541. */
  18542. readonly visibility: number;
  18543. /**
  18544. * Skeleton of the source mesh
  18545. */
  18546. readonly skeleton: Nullable<Skeleton>;
  18547. /**
  18548. * Rendering ground id of the source mesh
  18549. */
  18550. renderingGroupId: number;
  18551. /**
  18552. * Returns the total number of vertices (integer).
  18553. */
  18554. getTotalVertices(): number;
  18555. /**
  18556. * Returns a positive integer : the total number of indices in this mesh geometry.
  18557. * @returns the numner of indices or zero if the mesh has no geometry.
  18558. */
  18559. getTotalIndices(): number;
  18560. /**
  18561. * The source mesh of the instance
  18562. */
  18563. readonly sourceMesh: Mesh;
  18564. /**
  18565. * Is this node ready to be used/rendered
  18566. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18567. * @return {boolean} is it ready
  18568. */
  18569. isReady(completeCheck?: boolean): boolean;
  18570. /**
  18571. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18572. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18573. * @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.
  18574. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18575. */
  18576. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18577. /**
  18578. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18579. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18580. * The `data` are either a numeric array either a Float32Array.
  18581. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18582. * 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).
  18583. * Note that a new underlying VertexBuffer object is created each call.
  18584. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18585. *
  18586. * Possible `kind` values :
  18587. * - VertexBuffer.PositionKind
  18588. * - VertexBuffer.UVKind
  18589. * - VertexBuffer.UV2Kind
  18590. * - VertexBuffer.UV3Kind
  18591. * - VertexBuffer.UV4Kind
  18592. * - VertexBuffer.UV5Kind
  18593. * - VertexBuffer.UV6Kind
  18594. * - VertexBuffer.ColorKind
  18595. * - VertexBuffer.MatricesIndicesKind
  18596. * - VertexBuffer.MatricesIndicesExtraKind
  18597. * - VertexBuffer.MatricesWeightsKind
  18598. * - VertexBuffer.MatricesWeightsExtraKind
  18599. *
  18600. * Returns the Mesh.
  18601. */
  18602. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18603. /**
  18604. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18605. * If the mesh has no geometry, it is simply returned as it is.
  18606. * The `data` are either a numeric array either a Float32Array.
  18607. * No new underlying VertexBuffer object is created.
  18608. * 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.
  18609. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18610. *
  18611. * Possible `kind` values :
  18612. * - VertexBuffer.PositionKind
  18613. * - VertexBuffer.UVKind
  18614. * - VertexBuffer.UV2Kind
  18615. * - VertexBuffer.UV3Kind
  18616. * - VertexBuffer.UV4Kind
  18617. * - VertexBuffer.UV5Kind
  18618. * - VertexBuffer.UV6Kind
  18619. * - VertexBuffer.ColorKind
  18620. * - VertexBuffer.MatricesIndicesKind
  18621. * - VertexBuffer.MatricesIndicesExtraKind
  18622. * - VertexBuffer.MatricesWeightsKind
  18623. * - VertexBuffer.MatricesWeightsExtraKind
  18624. *
  18625. * Returns the Mesh.
  18626. */
  18627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18628. /**
  18629. * Sets the mesh indices.
  18630. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18631. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18632. * This method creates a new index buffer each call.
  18633. * Returns the Mesh.
  18634. */
  18635. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18636. /**
  18637. * Boolean : True if the mesh owns the requested kind of data.
  18638. */
  18639. isVerticesDataPresent(kind: string): boolean;
  18640. /**
  18641. * Returns an array of indices (IndicesArray).
  18642. */
  18643. getIndices(): Nullable<IndicesArray>;
  18644. readonly _positions: Nullable<Vector3[]>;
  18645. /**
  18646. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18647. * This means the mesh underlying bounding box and sphere are recomputed.
  18648. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18649. * @returns the current mesh
  18650. */
  18651. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18652. /** @hidden */
  18653. _preActivate(): InstancedMesh;
  18654. /** @hidden */
  18655. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18656. /** @hidden */
  18657. _postActivate(): void;
  18658. getWorldMatrix(): Matrix;
  18659. readonly isAnInstance: boolean;
  18660. /**
  18661. * Returns the current associated LOD AbstractMesh.
  18662. */
  18663. getLOD(camera: Camera): AbstractMesh;
  18664. /** @hidden */
  18665. _syncSubMeshes(): InstancedMesh;
  18666. /** @hidden */
  18667. _generatePointsArray(): boolean;
  18668. /**
  18669. * Creates a new InstancedMesh from the current mesh.
  18670. * - name (string) : the cloned mesh name
  18671. * - newParent (optional Node) : the optional Node to parent the clone to.
  18672. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18673. *
  18674. * Returns the clone.
  18675. */
  18676. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18677. /**
  18678. * Disposes the InstancedMesh.
  18679. * Returns nothing.
  18680. */
  18681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18682. }
  18683. }
  18684. declare module BABYLON {
  18685. /**
  18686. * Defines the options associated with the creation of a shader material.
  18687. */
  18688. export interface IShaderMaterialOptions {
  18689. /**
  18690. * Does the material work in alpha blend mode
  18691. */
  18692. needAlphaBlending: boolean;
  18693. /**
  18694. * Does the material work in alpha test mode
  18695. */
  18696. needAlphaTesting: boolean;
  18697. /**
  18698. * The list of attribute names used in the shader
  18699. */
  18700. attributes: string[];
  18701. /**
  18702. * The list of unifrom names used in the shader
  18703. */
  18704. uniforms: string[];
  18705. /**
  18706. * The list of UBO names used in the shader
  18707. */
  18708. uniformBuffers: string[];
  18709. /**
  18710. * The list of sampler names used in the shader
  18711. */
  18712. samplers: string[];
  18713. /**
  18714. * The list of defines used in the shader
  18715. */
  18716. defines: string[];
  18717. }
  18718. /**
  18719. * 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.
  18720. *
  18721. * This returned material effects how the mesh will look based on the code in the shaders.
  18722. *
  18723. * @see http://doc.babylonjs.com/how_to/shader_material
  18724. */
  18725. export class ShaderMaterial extends Material {
  18726. private _shaderPath;
  18727. private _options;
  18728. private _textures;
  18729. private _textureArrays;
  18730. private _floats;
  18731. private _ints;
  18732. private _floatsArrays;
  18733. private _colors3;
  18734. private _colors3Arrays;
  18735. private _colors4;
  18736. private _colors4Arrays;
  18737. private _vectors2;
  18738. private _vectors3;
  18739. private _vectors4;
  18740. private _matrices;
  18741. private _matrices3x3;
  18742. private _matrices2x2;
  18743. private _vectors2Arrays;
  18744. private _vectors3Arrays;
  18745. private _vectors4Arrays;
  18746. private _cachedWorldViewMatrix;
  18747. private _cachedWorldViewProjectionMatrix;
  18748. private _renderId;
  18749. /**
  18750. * Instantiate a new shader material.
  18751. * 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.
  18752. * This returned material effects how the mesh will look based on the code in the shaders.
  18753. * @see http://doc.babylonjs.com/how_to/shader_material
  18754. * @param name Define the name of the material in the scene
  18755. * @param scene Define the scene the material belongs to
  18756. * @param shaderPath Defines the route to the shader code in one of three ways:
  18757. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18758. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18759. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18760. * @param options Define the options used to create the shader
  18761. */
  18762. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18763. /**
  18764. * Gets the options used to compile the shader.
  18765. * They can be modified to trigger a new compilation
  18766. */
  18767. readonly options: IShaderMaterialOptions;
  18768. /**
  18769. * Gets the current class name of the material e.g. "ShaderMaterial"
  18770. * Mainly use in serialization.
  18771. * @returns the class name
  18772. */
  18773. getClassName(): string;
  18774. /**
  18775. * Specifies if the material will require alpha blending
  18776. * @returns a boolean specifying if alpha blending is needed
  18777. */
  18778. needAlphaBlending(): boolean;
  18779. /**
  18780. * Specifies if this material should be rendered in alpha test mode
  18781. * @returns a boolean specifying if an alpha test is needed.
  18782. */
  18783. needAlphaTesting(): boolean;
  18784. private _checkUniform;
  18785. /**
  18786. * Set a texture in the shader.
  18787. * @param name Define the name of the uniform samplers as defined in the shader
  18788. * @param texture Define the texture to bind to this sampler
  18789. * @return the material itself allowing "fluent" like uniform updates
  18790. */
  18791. setTexture(name: string, texture: Texture): ShaderMaterial;
  18792. /**
  18793. * Set a texture array in the shader.
  18794. * @param name Define the name of the uniform sampler array as defined in the shader
  18795. * @param textures Define the list of textures to bind to this sampler
  18796. * @return the material itself allowing "fluent" like uniform updates
  18797. */
  18798. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18799. /**
  18800. * Set a float in the shader.
  18801. * @param name Define the name of the uniform as defined in the shader
  18802. * @param value Define the value to give to the uniform
  18803. * @return the material itself allowing "fluent" like uniform updates
  18804. */
  18805. setFloat(name: string, value: number): ShaderMaterial;
  18806. /**
  18807. * Set a int in the shader.
  18808. * @param name Define the name of the uniform as defined in the shader
  18809. * @param value Define the value to give to the uniform
  18810. * @return the material itself allowing "fluent" like uniform updates
  18811. */
  18812. setInt(name: string, value: number): ShaderMaterial;
  18813. /**
  18814. * Set an array of floats in the shader.
  18815. * @param name Define the name of the uniform as defined in the shader
  18816. * @param value Define the value to give to the uniform
  18817. * @return the material itself allowing "fluent" like uniform updates
  18818. */
  18819. setFloats(name: string, value: number[]): ShaderMaterial;
  18820. /**
  18821. * Set a vec3 in the shader from a Color3.
  18822. * @param name Define the name of the uniform as defined in the shader
  18823. * @param value Define the value to give to the uniform
  18824. * @return the material itself allowing "fluent" like uniform updates
  18825. */
  18826. setColor3(name: string, value: Color3): ShaderMaterial;
  18827. /**
  18828. * Set a vec3 array in the shader from a Color3 array.
  18829. * @param name Define the name of the uniform as defined in the shader
  18830. * @param value Define the value to give to the uniform
  18831. * @return the material itself allowing "fluent" like uniform updates
  18832. */
  18833. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18834. /**
  18835. * Set a vec4 in the shader from a Color4.
  18836. * @param name Define the name of the uniform as defined in the shader
  18837. * @param value Define the value to give to the uniform
  18838. * @return the material itself allowing "fluent" like uniform updates
  18839. */
  18840. setColor4(name: string, value: Color4): ShaderMaterial;
  18841. /**
  18842. * Set a vec4 array in the shader from a Color4 array.
  18843. * @param name Define the name of the uniform as defined in the shader
  18844. * @param value Define the value to give to the uniform
  18845. * @return the material itself allowing "fluent" like uniform updates
  18846. */
  18847. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18848. /**
  18849. * Set a vec2 in the shader from a Vector2.
  18850. * @param name Define the name of the uniform as defined in the shader
  18851. * @param value Define the value to give to the uniform
  18852. * @return the material itself allowing "fluent" like uniform updates
  18853. */
  18854. setVector2(name: string, value: Vector2): ShaderMaterial;
  18855. /**
  18856. * Set a vec3 in the shader from a Vector3.
  18857. * @param name Define the name of the uniform as defined in the shader
  18858. * @param value Define the value to give to the uniform
  18859. * @return the material itself allowing "fluent" like uniform updates
  18860. */
  18861. setVector3(name: string, value: Vector3): ShaderMaterial;
  18862. /**
  18863. * Set a vec4 in the shader from a Vector4.
  18864. * @param name Define the name of the uniform as defined in the shader
  18865. * @param value Define the value to give to the uniform
  18866. * @return the material itself allowing "fluent" like uniform updates
  18867. */
  18868. setVector4(name: string, value: Vector4): ShaderMaterial;
  18869. /**
  18870. * Set a mat4 in the shader from a Matrix.
  18871. * @param name Define the name of the uniform as defined in the shader
  18872. * @param value Define the value to give to the uniform
  18873. * @return the material itself allowing "fluent" like uniform updates
  18874. */
  18875. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18876. /**
  18877. * Set a mat3 in the shader from a Float32Array.
  18878. * @param name Define the name of the uniform as defined in the shader
  18879. * @param value Define the value to give to the uniform
  18880. * @return the material itself allowing "fluent" like uniform updates
  18881. */
  18882. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18883. /**
  18884. * Set a mat2 in the shader from a Float32Array.
  18885. * @param name Define the name of the uniform as defined in the shader
  18886. * @param value Define the value to give to the uniform
  18887. * @return the material itself allowing "fluent" like uniform updates
  18888. */
  18889. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18890. /**
  18891. * Set a vec2 array in the shader from a number array.
  18892. * @param name Define the name of the uniform as defined in the shader
  18893. * @param value Define the value to give to the uniform
  18894. * @return the material itself allowing "fluent" like uniform updates
  18895. */
  18896. setArray2(name: string, value: number[]): ShaderMaterial;
  18897. /**
  18898. * Set a vec3 array in the shader from a number array.
  18899. * @param name Define the name of the uniform as defined in the shader
  18900. * @param value Define the value to give to the uniform
  18901. * @return the material itself allowing "fluent" like uniform updates
  18902. */
  18903. setArray3(name: string, value: number[]): ShaderMaterial;
  18904. /**
  18905. * Set a vec4 array in the shader from a number array.
  18906. * @param name Define the name of the uniform as defined in the shader
  18907. * @param value Define the value to give to the uniform
  18908. * @return the material itself allowing "fluent" like uniform updates
  18909. */
  18910. setArray4(name: string, value: number[]): ShaderMaterial;
  18911. private _checkCache;
  18912. /**
  18913. * Specifies that the submesh is ready to be used
  18914. * @param mesh defines the mesh to check
  18915. * @param subMesh defines which submesh to check
  18916. * @param useInstances specifies that instances should be used
  18917. * @returns a boolean indicating that the submesh is ready or not
  18918. */
  18919. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18920. /**
  18921. * Checks if the material is ready to render the requested mesh
  18922. * @param mesh Define the mesh to render
  18923. * @param useInstances Define whether or not the material is used with instances
  18924. * @returns true if ready, otherwise false
  18925. */
  18926. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18927. /**
  18928. * Binds the world matrix to the material
  18929. * @param world defines the world transformation matrix
  18930. */
  18931. bindOnlyWorldMatrix(world: Matrix): void;
  18932. /**
  18933. * Binds the material to the mesh
  18934. * @param world defines the world transformation matrix
  18935. * @param mesh defines the mesh to bind the material to
  18936. */
  18937. bind(world: Matrix, mesh?: Mesh): void;
  18938. /**
  18939. * Gets the active textures from the material
  18940. * @returns an array of textures
  18941. */
  18942. getActiveTextures(): BaseTexture[];
  18943. /**
  18944. * Specifies if the material uses a texture
  18945. * @param texture defines the texture to check against the material
  18946. * @returns a boolean specifying if the material uses the texture
  18947. */
  18948. hasTexture(texture: BaseTexture): boolean;
  18949. /**
  18950. * Makes a duplicate of the material, and gives it a new name
  18951. * @param name defines the new name for the duplicated material
  18952. * @returns the cloned material
  18953. */
  18954. clone(name: string): ShaderMaterial;
  18955. /**
  18956. * Disposes the material
  18957. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18958. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18959. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18960. */
  18961. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18962. /**
  18963. * Serializes this material in a JSON representation
  18964. * @returns the serialized material object
  18965. */
  18966. serialize(): any;
  18967. /**
  18968. * Creates a shader material from parsed shader material data
  18969. * @param source defines the JSON represnetation of the material
  18970. * @param scene defines the hosting scene
  18971. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18972. * @returns a new material
  18973. */
  18974. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18975. }
  18976. }
  18977. declare module BABYLON {
  18978. /** @hidden */
  18979. export var colorPixelShader: {
  18980. name: string;
  18981. shader: string;
  18982. };
  18983. }
  18984. declare module BABYLON {
  18985. /** @hidden */
  18986. export var colorVertexShader: {
  18987. name: string;
  18988. shader: string;
  18989. };
  18990. }
  18991. declare module BABYLON {
  18992. /**
  18993. * Line mesh
  18994. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18995. */
  18996. export class LinesMesh extends Mesh {
  18997. /**
  18998. * If vertex color should be applied to the mesh
  18999. */
  19000. readonly useVertexColor?: boolean | undefined;
  19001. /**
  19002. * If vertex alpha should be applied to the mesh
  19003. */
  19004. readonly useVertexAlpha?: boolean | undefined;
  19005. /**
  19006. * Color of the line (Default: White)
  19007. */
  19008. color: Color3;
  19009. /**
  19010. * Alpha of the line (Default: 1)
  19011. */
  19012. alpha: number;
  19013. /**
  19014. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19015. * This margin is expressed in world space coordinates, so its value may vary.
  19016. * Default value is 0.1
  19017. */
  19018. intersectionThreshold: number;
  19019. private _colorShader;
  19020. private color4;
  19021. /**
  19022. * Creates a new LinesMesh
  19023. * @param name defines the name
  19024. * @param scene defines the hosting scene
  19025. * @param parent defines the parent mesh if any
  19026. * @param source defines the optional source LinesMesh used to clone data from
  19027. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19028. * When false, achieved by calling a clone(), also passing False.
  19029. * This will make creation of children, recursive.
  19030. * @param useVertexColor defines if this LinesMesh supports vertex color
  19031. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19032. */
  19033. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19034. /**
  19035. * If vertex color should be applied to the mesh
  19036. */
  19037. useVertexColor?: boolean | undefined,
  19038. /**
  19039. * If vertex alpha should be applied to the mesh
  19040. */
  19041. useVertexAlpha?: boolean | undefined);
  19042. private _addClipPlaneDefine;
  19043. private _removeClipPlaneDefine;
  19044. isReady(): boolean;
  19045. /**
  19046. * Returns the string "LineMesh"
  19047. */
  19048. getClassName(): string;
  19049. /**
  19050. * @hidden
  19051. */
  19052. /**
  19053. * @hidden
  19054. */
  19055. material: Material;
  19056. /**
  19057. * @hidden
  19058. */
  19059. readonly checkCollisions: boolean;
  19060. /** @hidden */
  19061. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19062. /** @hidden */
  19063. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19064. /**
  19065. * Disposes of the line mesh
  19066. * @param doNotRecurse If children should be disposed
  19067. */
  19068. dispose(doNotRecurse?: boolean): void;
  19069. /**
  19070. * Returns a new LineMesh object cloned from the current one.
  19071. */
  19072. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19073. /**
  19074. * Creates a new InstancedLinesMesh object from the mesh model.
  19075. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19076. * @param name defines the name of the new instance
  19077. * @returns a new InstancedLinesMesh
  19078. */
  19079. createInstance(name: string): InstancedLinesMesh;
  19080. }
  19081. /**
  19082. * Creates an instance based on a source LinesMesh
  19083. */
  19084. export class InstancedLinesMesh extends InstancedMesh {
  19085. /**
  19086. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19087. * This margin is expressed in world space coordinates, so its value may vary.
  19088. * Initilized with the intersectionThreshold value of the source LinesMesh
  19089. */
  19090. intersectionThreshold: number;
  19091. constructor(name: string, source: LinesMesh);
  19092. /**
  19093. * Returns the string "InstancedLinesMesh".
  19094. */
  19095. getClassName(): string;
  19096. }
  19097. }
  19098. declare module BABYLON {
  19099. /** @hidden */
  19100. export var linePixelShader: {
  19101. name: string;
  19102. shader: string;
  19103. };
  19104. }
  19105. declare module BABYLON {
  19106. /** @hidden */
  19107. export var lineVertexShader: {
  19108. name: string;
  19109. shader: string;
  19110. };
  19111. }
  19112. declare module BABYLON {
  19113. interface AbstractMesh {
  19114. /**
  19115. * Gets the edgesRenderer associated with the mesh
  19116. */
  19117. edgesRenderer: Nullable<EdgesRenderer>;
  19118. }
  19119. interface LinesMesh {
  19120. /**
  19121. * Enables the edge rendering mode on the mesh.
  19122. * This mode makes the mesh edges visible
  19123. * @param epsilon defines the maximal distance between two angles to detect a face
  19124. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19125. * @returns the currentAbstractMesh
  19126. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19127. */
  19128. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19129. }
  19130. interface InstancedLinesMesh {
  19131. /**
  19132. * Enables the edge rendering mode on the mesh.
  19133. * This mode makes the mesh edges visible
  19134. * @param epsilon defines the maximal distance between two angles to detect a face
  19135. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19136. * @returns the current InstancedLinesMesh
  19137. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19138. */
  19139. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19140. }
  19141. /**
  19142. * Defines the minimum contract an Edges renderer should follow.
  19143. */
  19144. export interface IEdgesRenderer extends IDisposable {
  19145. /**
  19146. * Gets or sets a boolean indicating if the edgesRenderer is active
  19147. */
  19148. isEnabled: boolean;
  19149. /**
  19150. * Renders the edges of the attached mesh,
  19151. */
  19152. render(): void;
  19153. /**
  19154. * Checks wether or not the edges renderer is ready to render.
  19155. * @return true if ready, otherwise false.
  19156. */
  19157. isReady(): boolean;
  19158. }
  19159. /**
  19160. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19161. */
  19162. export class EdgesRenderer implements IEdgesRenderer {
  19163. /**
  19164. * Define the size of the edges with an orthographic camera
  19165. */
  19166. edgesWidthScalerForOrthographic: number;
  19167. /**
  19168. * Define the size of the edges with a perspective camera
  19169. */
  19170. edgesWidthScalerForPerspective: number;
  19171. protected _source: AbstractMesh;
  19172. protected _linesPositions: number[];
  19173. protected _linesNormals: number[];
  19174. protected _linesIndices: number[];
  19175. protected _epsilon: number;
  19176. protected _indicesCount: number;
  19177. protected _lineShader: ShaderMaterial;
  19178. protected _ib: DataBuffer;
  19179. protected _buffers: {
  19180. [key: string]: Nullable<VertexBuffer>;
  19181. };
  19182. protected _checkVerticesInsteadOfIndices: boolean;
  19183. private _meshRebuildObserver;
  19184. private _meshDisposeObserver;
  19185. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19186. isEnabled: boolean;
  19187. /**
  19188. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19189. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19190. * @param source Mesh used to create edges
  19191. * @param epsilon sum of angles in adjacency to check for edge
  19192. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19193. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19194. */
  19195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19196. protected _prepareRessources(): void;
  19197. /** @hidden */
  19198. _rebuild(): void;
  19199. /**
  19200. * Releases the required resources for the edges renderer
  19201. */
  19202. dispose(): void;
  19203. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19204. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19205. /**
  19206. * Checks if the pair of p0 and p1 is en edge
  19207. * @param faceIndex
  19208. * @param edge
  19209. * @param faceNormals
  19210. * @param p0
  19211. * @param p1
  19212. * @private
  19213. */
  19214. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19215. /**
  19216. * push line into the position, normal and index buffer
  19217. * @protected
  19218. */
  19219. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19220. /**
  19221. * Generates lines edges from adjacencjes
  19222. * @private
  19223. */
  19224. _generateEdgesLines(): void;
  19225. /**
  19226. * Checks wether or not the edges renderer is ready to render.
  19227. * @return true if ready, otherwise false.
  19228. */
  19229. isReady(): boolean;
  19230. /**
  19231. * Renders the edges of the attached mesh,
  19232. */
  19233. render(): void;
  19234. }
  19235. /**
  19236. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19237. */
  19238. export class LineEdgesRenderer extends EdgesRenderer {
  19239. /**
  19240. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19241. * @param source LineMesh used to generate edges
  19242. * @param epsilon not important (specified angle for edge detection)
  19243. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19244. */
  19245. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19246. /**
  19247. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19248. */
  19249. _generateEdgesLines(): void;
  19250. }
  19251. }
  19252. declare module BABYLON {
  19253. /**
  19254. * This represents the object necessary to create a rendering group.
  19255. * This is exclusively used and created by the rendering manager.
  19256. * To modify the behavior, you use the available helpers in your scene or meshes.
  19257. * @hidden
  19258. */
  19259. export class RenderingGroup {
  19260. index: number;
  19261. private static _zeroVector;
  19262. private _scene;
  19263. private _opaqueSubMeshes;
  19264. private _transparentSubMeshes;
  19265. private _alphaTestSubMeshes;
  19266. private _depthOnlySubMeshes;
  19267. private _particleSystems;
  19268. private _spriteManagers;
  19269. private _opaqueSortCompareFn;
  19270. private _alphaTestSortCompareFn;
  19271. private _transparentSortCompareFn;
  19272. private _renderOpaque;
  19273. private _renderAlphaTest;
  19274. private _renderTransparent;
  19275. /** @hidden */
  19276. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19277. onBeforeTransparentRendering: () => void;
  19278. /**
  19279. * Set the opaque sort comparison function.
  19280. * If null the sub meshes will be render in the order they were created
  19281. */
  19282. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19283. /**
  19284. * Set the alpha test sort comparison function.
  19285. * If null the sub meshes will be render in the order they were created
  19286. */
  19287. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19288. /**
  19289. * Set the transparent sort comparison function.
  19290. * If null the sub meshes will be render in the order they were created
  19291. */
  19292. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19293. /**
  19294. * Creates a new rendering group.
  19295. * @param index The rendering group index
  19296. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19297. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19298. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19299. */
  19300. 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>);
  19301. /**
  19302. * Render all the sub meshes contained in the group.
  19303. * @param customRenderFunction Used to override the default render behaviour of the group.
  19304. * @returns true if rendered some submeshes.
  19305. */
  19306. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19307. /**
  19308. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19309. * @param subMeshes The submeshes to render
  19310. */
  19311. private renderOpaqueSorted;
  19312. /**
  19313. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19314. * @param subMeshes The submeshes to render
  19315. */
  19316. private renderAlphaTestSorted;
  19317. /**
  19318. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19319. * @param subMeshes The submeshes to render
  19320. */
  19321. private renderTransparentSorted;
  19322. /**
  19323. * Renders the submeshes in a specified order.
  19324. * @param subMeshes The submeshes to sort before render
  19325. * @param sortCompareFn The comparison function use to sort
  19326. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19327. * @param transparent Specifies to activate blending if true
  19328. */
  19329. private static renderSorted;
  19330. /**
  19331. * Renders the submeshes in the order they were dispatched (no sort applied).
  19332. * @param subMeshes The submeshes to render
  19333. */
  19334. private static renderUnsorted;
  19335. /**
  19336. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19337. * are rendered back to front if in the same alpha index.
  19338. *
  19339. * @param a The first submesh
  19340. * @param b The second submesh
  19341. * @returns The result of the comparison
  19342. */
  19343. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19344. /**
  19345. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19346. * are rendered back to front.
  19347. *
  19348. * @param a The first submesh
  19349. * @param b The second submesh
  19350. * @returns The result of the comparison
  19351. */
  19352. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19353. /**
  19354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19355. * are rendered front to back (prevent overdraw).
  19356. *
  19357. * @param a The first submesh
  19358. * @param b The second submesh
  19359. * @returns The result of the comparison
  19360. */
  19361. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19362. /**
  19363. * Resets the different lists of submeshes to prepare a new frame.
  19364. */
  19365. prepare(): void;
  19366. dispose(): void;
  19367. /**
  19368. * Inserts the submesh in its correct queue depending on its material.
  19369. * @param subMesh The submesh to dispatch
  19370. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19371. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19372. */
  19373. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19374. dispatchSprites(spriteManager: ISpriteManager): void;
  19375. dispatchParticles(particleSystem: IParticleSystem): void;
  19376. private _renderParticles;
  19377. private _renderSprites;
  19378. }
  19379. }
  19380. declare module BABYLON {
  19381. /**
  19382. * Interface describing the different options available in the rendering manager
  19383. * regarding Auto Clear between groups.
  19384. */
  19385. export interface IRenderingManagerAutoClearSetup {
  19386. /**
  19387. * Defines whether or not autoclear is enable.
  19388. */
  19389. autoClear: boolean;
  19390. /**
  19391. * Defines whether or not to autoclear the depth buffer.
  19392. */
  19393. depth: boolean;
  19394. /**
  19395. * Defines whether or not to autoclear the stencil buffer.
  19396. */
  19397. stencil: boolean;
  19398. }
  19399. /**
  19400. * This class is used by the onRenderingGroupObservable
  19401. */
  19402. export class RenderingGroupInfo {
  19403. /**
  19404. * The Scene that being rendered
  19405. */
  19406. scene: Scene;
  19407. /**
  19408. * The camera currently used for the rendering pass
  19409. */
  19410. camera: Nullable<Camera>;
  19411. /**
  19412. * The ID of the renderingGroup being processed
  19413. */
  19414. renderingGroupId: number;
  19415. }
  19416. /**
  19417. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19418. * It is enable to manage the different groups as well as the different necessary sort functions.
  19419. * This should not be used directly aside of the few static configurations
  19420. */
  19421. export class RenderingManager {
  19422. /**
  19423. * The max id used for rendering groups (not included)
  19424. */
  19425. static MAX_RENDERINGGROUPS: number;
  19426. /**
  19427. * The min id used for rendering groups (included)
  19428. */
  19429. static MIN_RENDERINGGROUPS: number;
  19430. /**
  19431. * Used to globally prevent autoclearing scenes.
  19432. */
  19433. static AUTOCLEAR: boolean;
  19434. /**
  19435. * @hidden
  19436. */
  19437. _useSceneAutoClearSetup: boolean;
  19438. private _scene;
  19439. private _renderingGroups;
  19440. private _depthStencilBufferAlreadyCleaned;
  19441. private _autoClearDepthStencil;
  19442. private _customOpaqueSortCompareFn;
  19443. private _customAlphaTestSortCompareFn;
  19444. private _customTransparentSortCompareFn;
  19445. private _renderingGroupInfo;
  19446. /**
  19447. * Instantiates a new rendering group for a particular scene
  19448. * @param scene Defines the scene the groups belongs to
  19449. */
  19450. constructor(scene: Scene);
  19451. private _clearDepthStencilBuffer;
  19452. /**
  19453. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19454. * @hidden
  19455. */
  19456. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19457. /**
  19458. * Resets the different information of the group to prepare a new frame
  19459. * @hidden
  19460. */
  19461. reset(): void;
  19462. /**
  19463. * Dispose and release the group and its associated resources.
  19464. * @hidden
  19465. */
  19466. dispose(): void;
  19467. /**
  19468. * Clear the info related to rendering groups preventing retention points during dispose.
  19469. */
  19470. freeRenderingGroups(): void;
  19471. private _prepareRenderingGroup;
  19472. /**
  19473. * Add a sprite manager to the rendering manager in order to render it this frame.
  19474. * @param spriteManager Define the sprite manager to render
  19475. */
  19476. dispatchSprites(spriteManager: ISpriteManager): void;
  19477. /**
  19478. * Add a particle system to the rendering manager in order to render it this frame.
  19479. * @param particleSystem Define the particle system to render
  19480. */
  19481. dispatchParticles(particleSystem: IParticleSystem): void;
  19482. /**
  19483. * Add a submesh to the manager in order to render it this frame
  19484. * @param subMesh The submesh to dispatch
  19485. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19486. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19487. */
  19488. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19489. /**
  19490. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19491. * This allowed control for front to back rendering or reversly depending of the special needs.
  19492. *
  19493. * @param renderingGroupId The rendering group id corresponding to its index
  19494. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19495. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19496. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19497. */
  19498. 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;
  19499. /**
  19500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19501. *
  19502. * @param renderingGroupId The rendering group id corresponding to its index
  19503. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19504. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19505. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19506. */
  19507. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19508. /**
  19509. * Gets the current auto clear configuration for one rendering group of the rendering
  19510. * manager.
  19511. * @param index the rendering group index to get the information for
  19512. * @returns The auto clear setup for the requested rendering group
  19513. */
  19514. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19515. }
  19516. }
  19517. declare module BABYLON {
  19518. /**
  19519. * This Helps creating a texture that will be created from a camera in your scene.
  19520. * It is basically a dynamic texture that could be used to create special effects for instance.
  19521. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19522. */
  19523. export class RenderTargetTexture extends Texture {
  19524. isCube: boolean;
  19525. /**
  19526. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19527. */
  19528. static readonly REFRESHRATE_RENDER_ONCE: number;
  19529. /**
  19530. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19531. */
  19532. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19533. /**
  19534. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19535. * the central point of your effect and can save a lot of performances.
  19536. */
  19537. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19538. /**
  19539. * Use this predicate to dynamically define the list of mesh you want to render.
  19540. * If set, the renderList property will be overwritten.
  19541. */
  19542. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19543. private _renderList;
  19544. /**
  19545. * Use this list to define the list of mesh you want to render.
  19546. */
  19547. renderList: Nullable<Array<AbstractMesh>>;
  19548. private _hookArray;
  19549. /**
  19550. * Define if particles should be rendered in your texture.
  19551. */
  19552. renderParticles: boolean;
  19553. /**
  19554. * Define if sprites should be rendered in your texture.
  19555. */
  19556. renderSprites: boolean;
  19557. /**
  19558. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19559. */
  19560. coordinatesMode: number;
  19561. /**
  19562. * Define the camera used to render the texture.
  19563. */
  19564. activeCamera: Nullable<Camera>;
  19565. /**
  19566. * Override the render function of the texture with your own one.
  19567. */
  19568. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19569. /**
  19570. * Define if camera post processes should be use while rendering the texture.
  19571. */
  19572. useCameraPostProcesses: boolean;
  19573. /**
  19574. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19575. */
  19576. ignoreCameraViewport: boolean;
  19577. private _postProcessManager;
  19578. private _postProcesses;
  19579. private _resizeObserver;
  19580. /**
  19581. * An event triggered when the texture is unbind.
  19582. */
  19583. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19584. /**
  19585. * An event triggered when the texture is unbind.
  19586. */
  19587. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19588. private _onAfterUnbindObserver;
  19589. /**
  19590. * Set a after unbind callback in the texture.
  19591. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19592. */
  19593. onAfterUnbind: () => void;
  19594. /**
  19595. * An event triggered before rendering the texture
  19596. */
  19597. onBeforeRenderObservable: Observable<number>;
  19598. private _onBeforeRenderObserver;
  19599. /**
  19600. * Set a before render callback in the texture.
  19601. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19602. */
  19603. onBeforeRender: (faceIndex: number) => void;
  19604. /**
  19605. * An event triggered after rendering the texture
  19606. */
  19607. onAfterRenderObservable: Observable<number>;
  19608. private _onAfterRenderObserver;
  19609. /**
  19610. * Set a after render callback in the texture.
  19611. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19612. */
  19613. onAfterRender: (faceIndex: number) => void;
  19614. /**
  19615. * An event triggered after the texture clear
  19616. */
  19617. onClearObservable: Observable<Engine>;
  19618. private _onClearObserver;
  19619. /**
  19620. * Set a clear callback in the texture.
  19621. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19622. */
  19623. onClear: (Engine: Engine) => void;
  19624. /**
  19625. * An event triggered when the texture is resized.
  19626. */
  19627. onResizeObservable: Observable<RenderTargetTexture>;
  19628. /**
  19629. * Define the clear color of the Render Target if it should be different from the scene.
  19630. */
  19631. clearColor: Color4;
  19632. protected _size: number | {
  19633. width: number;
  19634. height: number;
  19635. };
  19636. protected _initialSizeParameter: number | {
  19637. width: number;
  19638. height: number;
  19639. } | {
  19640. ratio: number;
  19641. };
  19642. protected _sizeRatio: Nullable<number>;
  19643. /** @hidden */
  19644. _generateMipMaps: boolean;
  19645. protected _renderingManager: RenderingManager;
  19646. /** @hidden */
  19647. _waitingRenderList: string[];
  19648. protected _doNotChangeAspectRatio: boolean;
  19649. protected _currentRefreshId: number;
  19650. protected _refreshRate: number;
  19651. protected _textureMatrix: Matrix;
  19652. protected _samples: number;
  19653. protected _renderTargetOptions: RenderTargetCreationOptions;
  19654. /**
  19655. * Gets render target creation options that were used.
  19656. */
  19657. readonly renderTargetOptions: RenderTargetCreationOptions;
  19658. protected _engine: Engine;
  19659. protected _onRatioRescale(): void;
  19660. /**
  19661. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19662. * It must define where the camera used to render the texture is set
  19663. */
  19664. boundingBoxPosition: Vector3;
  19665. private _boundingBoxSize;
  19666. /**
  19667. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19668. * When defined, the cubemap will switch to local mode
  19669. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19670. * @example https://www.babylonjs-playground.com/#RNASML
  19671. */
  19672. boundingBoxSize: Vector3;
  19673. /**
  19674. * In case the RTT has been created with a depth texture, get the associated
  19675. * depth texture.
  19676. * Otherwise, return null.
  19677. */
  19678. depthStencilTexture: Nullable<InternalTexture>;
  19679. /**
  19680. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19681. * or used a shadow, depth texture...
  19682. * @param name The friendly name of the texture
  19683. * @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)
  19684. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19685. * @param generateMipMaps True if mip maps need to be generated after render.
  19686. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19687. * @param type The type of the buffer in the RTT (int, half float, float...)
  19688. * @param isCube True if a cube texture needs to be created
  19689. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19690. * @param generateDepthBuffer True to generate a depth buffer
  19691. * @param generateStencilBuffer True to generate a stencil buffer
  19692. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19693. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19694. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19695. */
  19696. constructor(name: string, size: number | {
  19697. width: number;
  19698. height: number;
  19699. } | {
  19700. ratio: number;
  19701. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19702. /**
  19703. * Creates a depth stencil texture.
  19704. * This is only available in WebGL 2 or with the depth texture extension available.
  19705. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19706. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19707. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19708. */
  19709. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19710. private _processSizeParameter;
  19711. /**
  19712. * Define the number of samples to use in case of MSAA.
  19713. * It defaults to one meaning no MSAA has been enabled.
  19714. */
  19715. samples: number;
  19716. /**
  19717. * Resets the refresh counter of the texture and start bak from scratch.
  19718. * Could be useful to regenerate the texture if it is setup to render only once.
  19719. */
  19720. resetRefreshCounter(): void;
  19721. /**
  19722. * Define the refresh rate of the texture or the rendering frequency.
  19723. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19724. */
  19725. refreshRate: number;
  19726. /**
  19727. * Adds a post process to the render target rendering passes.
  19728. * @param postProcess define the post process to add
  19729. */
  19730. addPostProcess(postProcess: PostProcess): void;
  19731. /**
  19732. * Clear all the post processes attached to the render target
  19733. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19734. */
  19735. clearPostProcesses(dispose?: boolean): void;
  19736. /**
  19737. * Remove one of the post process from the list of attached post processes to the texture
  19738. * @param postProcess define the post process to remove from the list
  19739. */
  19740. removePostProcess(postProcess: PostProcess): void;
  19741. /** @hidden */
  19742. _shouldRender(): boolean;
  19743. /**
  19744. * Gets the actual render size of the texture.
  19745. * @returns the width of the render size
  19746. */
  19747. getRenderSize(): number;
  19748. /**
  19749. * Gets the actual render width of the texture.
  19750. * @returns the width of the render size
  19751. */
  19752. getRenderWidth(): number;
  19753. /**
  19754. * Gets the actual render height of the texture.
  19755. * @returns the height of the render size
  19756. */
  19757. getRenderHeight(): number;
  19758. /**
  19759. * Get if the texture can be rescaled or not.
  19760. */
  19761. readonly canRescale: boolean;
  19762. /**
  19763. * Resize the texture using a ratio.
  19764. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19765. */
  19766. scale(ratio: number): void;
  19767. /**
  19768. * Get the texture reflection matrix used to rotate/transform the reflection.
  19769. * @returns the reflection matrix
  19770. */
  19771. getReflectionTextureMatrix(): Matrix;
  19772. /**
  19773. * Resize the texture to a new desired size.
  19774. * Be carrefull as it will recreate all the data in the new texture.
  19775. * @param size Define the new size. It can be:
  19776. * - a number for squared texture,
  19777. * - an object containing { width: number, height: number }
  19778. * - or an object containing a ratio { ratio: number }
  19779. */
  19780. resize(size: number | {
  19781. width: number;
  19782. height: number;
  19783. } | {
  19784. ratio: number;
  19785. }): void;
  19786. /**
  19787. * Renders all the objects from the render list into the texture.
  19788. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19789. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19790. */
  19791. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19792. private _bestReflectionRenderTargetDimension;
  19793. /**
  19794. * @hidden
  19795. * @param faceIndex face index to bind to if this is a cubetexture
  19796. */
  19797. _bindFrameBuffer(faceIndex?: number): void;
  19798. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19799. private renderToTarget;
  19800. /**
  19801. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19802. * This allowed control for front to back rendering or reversly depending of the special needs.
  19803. *
  19804. * @param renderingGroupId The rendering group id corresponding to its index
  19805. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19806. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19807. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19808. */
  19809. 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;
  19810. /**
  19811. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19812. *
  19813. * @param renderingGroupId The rendering group id corresponding to its index
  19814. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19815. */
  19816. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19817. /**
  19818. * Clones the texture.
  19819. * @returns the cloned texture
  19820. */
  19821. clone(): RenderTargetTexture;
  19822. /**
  19823. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19824. * @returns The JSON representation of the texture
  19825. */
  19826. serialize(): any;
  19827. /**
  19828. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19829. */
  19830. disposeFramebufferObjects(): void;
  19831. /**
  19832. * Dispose the texture and release its associated resources.
  19833. */
  19834. dispose(): void;
  19835. /** @hidden */
  19836. _rebuild(): void;
  19837. /**
  19838. * Clear the info related to rendering groups preventing retention point in material dispose.
  19839. */
  19840. freeRenderingGroups(): void;
  19841. /**
  19842. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19843. * @returns the view count
  19844. */
  19845. getViewCount(): number;
  19846. }
  19847. }
  19848. declare module BABYLON {
  19849. /**
  19850. * Base class for the main features of a material in Babylon.js
  19851. */
  19852. export class Material implements IAnimatable {
  19853. /**
  19854. * Returns the triangle fill mode
  19855. */
  19856. static readonly TriangleFillMode: number;
  19857. /**
  19858. * Returns the wireframe mode
  19859. */
  19860. static readonly WireFrameFillMode: number;
  19861. /**
  19862. * Returns the point fill mode
  19863. */
  19864. static readonly PointFillMode: number;
  19865. /**
  19866. * Returns the point list draw mode
  19867. */
  19868. static readonly PointListDrawMode: number;
  19869. /**
  19870. * Returns the line list draw mode
  19871. */
  19872. static readonly LineListDrawMode: number;
  19873. /**
  19874. * Returns the line loop draw mode
  19875. */
  19876. static readonly LineLoopDrawMode: number;
  19877. /**
  19878. * Returns the line strip draw mode
  19879. */
  19880. static readonly LineStripDrawMode: number;
  19881. /**
  19882. * Returns the triangle strip draw mode
  19883. */
  19884. static readonly TriangleStripDrawMode: number;
  19885. /**
  19886. * Returns the triangle fan draw mode
  19887. */
  19888. static readonly TriangleFanDrawMode: number;
  19889. /**
  19890. * Stores the clock-wise side orientation
  19891. */
  19892. static readonly ClockWiseSideOrientation: number;
  19893. /**
  19894. * Stores the counter clock-wise side orientation
  19895. */
  19896. static readonly CounterClockWiseSideOrientation: number;
  19897. /**
  19898. * The dirty texture flag value
  19899. */
  19900. static readonly TextureDirtyFlag: number;
  19901. /**
  19902. * The dirty light flag value
  19903. */
  19904. static readonly LightDirtyFlag: number;
  19905. /**
  19906. * The dirty fresnel flag value
  19907. */
  19908. static readonly FresnelDirtyFlag: number;
  19909. /**
  19910. * The dirty attribute flag value
  19911. */
  19912. static readonly AttributesDirtyFlag: number;
  19913. /**
  19914. * The dirty misc flag value
  19915. */
  19916. static readonly MiscDirtyFlag: number;
  19917. /**
  19918. * The all dirty flag value
  19919. */
  19920. static readonly AllDirtyFlag: number;
  19921. /**
  19922. * The ID of the material
  19923. */
  19924. id: string;
  19925. /**
  19926. * Gets or sets the unique id of the material
  19927. */
  19928. uniqueId: number;
  19929. /**
  19930. * The name of the material
  19931. */
  19932. name: string;
  19933. /**
  19934. * Gets or sets user defined metadata
  19935. */
  19936. metadata: any;
  19937. /**
  19938. * For internal use only. Please do not use.
  19939. */
  19940. reservedDataStore: any;
  19941. /**
  19942. * Specifies if the ready state should be checked on each call
  19943. */
  19944. checkReadyOnEveryCall: boolean;
  19945. /**
  19946. * Specifies if the ready state should be checked once
  19947. */
  19948. checkReadyOnlyOnce: boolean;
  19949. /**
  19950. * The state of the material
  19951. */
  19952. state: string;
  19953. /**
  19954. * The alpha value of the material
  19955. */
  19956. protected _alpha: number;
  19957. /**
  19958. * List of inspectable custom properties (used by the Inspector)
  19959. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19960. */
  19961. inspectableCustomProperties: IInspectable[];
  19962. /**
  19963. * Sets the alpha value of the material
  19964. */
  19965. /**
  19966. * Gets the alpha value of the material
  19967. */
  19968. alpha: number;
  19969. /**
  19970. * Specifies if back face culling is enabled
  19971. */
  19972. protected _backFaceCulling: boolean;
  19973. /**
  19974. * Sets the back-face culling state
  19975. */
  19976. /**
  19977. * Gets the back-face culling state
  19978. */
  19979. backFaceCulling: boolean;
  19980. /**
  19981. * Stores the value for side orientation
  19982. */
  19983. sideOrientation: number;
  19984. /**
  19985. * Callback triggered when the material is compiled
  19986. */
  19987. onCompiled: Nullable<(effect: Effect) => void>;
  19988. /**
  19989. * Callback triggered when an error occurs
  19990. */
  19991. onError: Nullable<(effect: Effect, errors: string) => void>;
  19992. /**
  19993. * Callback triggered to get the render target textures
  19994. */
  19995. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19996. /**
  19997. * Gets a boolean indicating that current material needs to register RTT
  19998. */
  19999. readonly hasRenderTargetTextures: boolean;
  20000. /**
  20001. * Specifies if the material should be serialized
  20002. */
  20003. doNotSerialize: boolean;
  20004. /**
  20005. * @hidden
  20006. */
  20007. _storeEffectOnSubMeshes: boolean;
  20008. /**
  20009. * Stores the animations for the material
  20010. */
  20011. animations: Nullable<Array<Animation>>;
  20012. /**
  20013. * An event triggered when the material is disposed
  20014. */
  20015. onDisposeObservable: Observable<Material>;
  20016. /**
  20017. * An observer which watches for dispose events
  20018. */
  20019. private _onDisposeObserver;
  20020. private _onUnBindObservable;
  20021. /**
  20022. * Called during a dispose event
  20023. */
  20024. onDispose: () => void;
  20025. private _onBindObservable;
  20026. /**
  20027. * An event triggered when the material is bound
  20028. */
  20029. readonly onBindObservable: Observable<AbstractMesh>;
  20030. /**
  20031. * An observer which watches for bind events
  20032. */
  20033. private _onBindObserver;
  20034. /**
  20035. * Called during a bind event
  20036. */
  20037. onBind: (Mesh: AbstractMesh) => void;
  20038. /**
  20039. * An event triggered when the material is unbound
  20040. */
  20041. readonly onUnBindObservable: Observable<Material>;
  20042. /**
  20043. * Stores the value of the alpha mode
  20044. */
  20045. private _alphaMode;
  20046. /**
  20047. * Sets the value of the alpha mode.
  20048. *
  20049. * | Value | Type | Description |
  20050. * | --- | --- | --- |
  20051. * | 0 | ALPHA_DISABLE | |
  20052. * | 1 | ALPHA_ADD | |
  20053. * | 2 | ALPHA_COMBINE | |
  20054. * | 3 | ALPHA_SUBTRACT | |
  20055. * | 4 | ALPHA_MULTIPLY | |
  20056. * | 5 | ALPHA_MAXIMIZED | |
  20057. * | 6 | ALPHA_ONEONE | |
  20058. * | 7 | ALPHA_PREMULTIPLIED | |
  20059. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20060. * | 9 | ALPHA_INTERPOLATE | |
  20061. * | 10 | ALPHA_SCREENMODE | |
  20062. *
  20063. */
  20064. /**
  20065. * Gets the value of the alpha mode
  20066. */
  20067. alphaMode: number;
  20068. /**
  20069. * Stores the state of the need depth pre-pass value
  20070. */
  20071. private _needDepthPrePass;
  20072. /**
  20073. * Sets the need depth pre-pass value
  20074. */
  20075. /**
  20076. * Gets the depth pre-pass value
  20077. */
  20078. needDepthPrePass: boolean;
  20079. /**
  20080. * Specifies if depth writing should be disabled
  20081. */
  20082. disableDepthWrite: boolean;
  20083. /**
  20084. * Specifies if depth writing should be forced
  20085. */
  20086. forceDepthWrite: boolean;
  20087. /**
  20088. * Specifies if there should be a separate pass for culling
  20089. */
  20090. separateCullingPass: boolean;
  20091. /**
  20092. * Stores the state specifing if fog should be enabled
  20093. */
  20094. private _fogEnabled;
  20095. /**
  20096. * Sets the state for enabling fog
  20097. */
  20098. /**
  20099. * Gets the value of the fog enabled state
  20100. */
  20101. fogEnabled: boolean;
  20102. /**
  20103. * Stores the size of points
  20104. */
  20105. pointSize: number;
  20106. /**
  20107. * Stores the z offset value
  20108. */
  20109. zOffset: number;
  20110. /**
  20111. * Gets a value specifying if wireframe mode is enabled
  20112. */
  20113. /**
  20114. * Sets the state of wireframe mode
  20115. */
  20116. wireframe: boolean;
  20117. /**
  20118. * Gets the value specifying if point clouds are enabled
  20119. */
  20120. /**
  20121. * Sets the state of point cloud mode
  20122. */
  20123. pointsCloud: boolean;
  20124. /**
  20125. * Gets the material fill mode
  20126. */
  20127. /**
  20128. * Sets the material fill mode
  20129. */
  20130. fillMode: number;
  20131. /**
  20132. * @hidden
  20133. * Stores the effects for the material
  20134. */
  20135. _effect: Nullable<Effect>;
  20136. /**
  20137. * @hidden
  20138. * Specifies if the material was previously ready
  20139. */
  20140. _wasPreviouslyReady: boolean;
  20141. /**
  20142. * Specifies if uniform buffers should be used
  20143. */
  20144. private _useUBO;
  20145. /**
  20146. * Stores a reference to the scene
  20147. */
  20148. private _scene;
  20149. /**
  20150. * Stores the fill mode state
  20151. */
  20152. private _fillMode;
  20153. /**
  20154. * Specifies if the depth write state should be cached
  20155. */
  20156. private _cachedDepthWriteState;
  20157. /**
  20158. * Stores the uniform buffer
  20159. */
  20160. protected _uniformBuffer: UniformBuffer;
  20161. /** @hidden */
  20162. _indexInSceneMaterialArray: number;
  20163. /** @hidden */
  20164. meshMap: Nullable<{
  20165. [id: string]: AbstractMesh | undefined;
  20166. }>;
  20167. /**
  20168. * Creates a material instance
  20169. * @param name defines the name of the material
  20170. * @param scene defines the scene to reference
  20171. * @param doNotAdd specifies if the material should be added to the scene
  20172. */
  20173. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20174. /**
  20175. * Returns a string representation of the current material
  20176. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20177. * @returns a string with material information
  20178. */
  20179. toString(fullDetails?: boolean): string;
  20180. /**
  20181. * Gets the class name of the material
  20182. * @returns a string with the class name of the material
  20183. */
  20184. getClassName(): string;
  20185. /**
  20186. * Specifies if updates for the material been locked
  20187. */
  20188. readonly isFrozen: boolean;
  20189. /**
  20190. * Locks updates for the material
  20191. */
  20192. freeze(): void;
  20193. /**
  20194. * Unlocks updates for the material
  20195. */
  20196. unfreeze(): void;
  20197. /**
  20198. * Specifies if the material is ready to be used
  20199. * @param mesh defines the mesh to check
  20200. * @param useInstances specifies if instances should be used
  20201. * @returns a boolean indicating if the material is ready to be used
  20202. */
  20203. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20204. /**
  20205. * Specifies that the submesh is ready to be used
  20206. * @param mesh defines the mesh to check
  20207. * @param subMesh defines which submesh to check
  20208. * @param useInstances specifies that instances should be used
  20209. * @returns a boolean indicating that the submesh is ready or not
  20210. */
  20211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20212. /**
  20213. * Returns the material effect
  20214. * @returns the effect associated with the material
  20215. */
  20216. getEffect(): Nullable<Effect>;
  20217. /**
  20218. * Returns the current scene
  20219. * @returns a Scene
  20220. */
  20221. getScene(): Scene;
  20222. /**
  20223. * Specifies if the material will require alpha blending
  20224. * @returns a boolean specifying if alpha blending is needed
  20225. */
  20226. needAlphaBlending(): boolean;
  20227. /**
  20228. * Specifies if the mesh will require alpha blending
  20229. * @param mesh defines the mesh to check
  20230. * @returns a boolean specifying if alpha blending is needed for the mesh
  20231. */
  20232. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20233. /**
  20234. * Specifies if this material should be rendered in alpha test mode
  20235. * @returns a boolean specifying if an alpha test is needed.
  20236. */
  20237. needAlphaTesting(): boolean;
  20238. /**
  20239. * Gets the texture used for the alpha test
  20240. * @returns the texture to use for alpha testing
  20241. */
  20242. getAlphaTestTexture(): Nullable<BaseTexture>;
  20243. /**
  20244. * Marks the material to indicate that it needs to be re-calculated
  20245. */
  20246. markDirty(): void;
  20247. /** @hidden */
  20248. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20249. /**
  20250. * Binds the material to the mesh
  20251. * @param world defines the world transformation matrix
  20252. * @param mesh defines the mesh to bind the material to
  20253. */
  20254. bind(world: Matrix, mesh?: Mesh): void;
  20255. /**
  20256. * Binds the submesh to the material
  20257. * @param world defines the world transformation matrix
  20258. * @param mesh defines the mesh containing the submesh
  20259. * @param subMesh defines the submesh to bind the material to
  20260. */
  20261. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20262. /**
  20263. * Binds the world matrix to the material
  20264. * @param world defines the world transformation matrix
  20265. */
  20266. bindOnlyWorldMatrix(world: Matrix): void;
  20267. /**
  20268. * Binds the scene's uniform buffer to the effect.
  20269. * @param effect defines the effect to bind to the scene uniform buffer
  20270. * @param sceneUbo defines the uniform buffer storing scene data
  20271. */
  20272. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20273. /**
  20274. * Binds the view matrix to the effect
  20275. * @param effect defines the effect to bind the view matrix to
  20276. */
  20277. bindView(effect: Effect): void;
  20278. /**
  20279. * Binds the view projection matrix to the effect
  20280. * @param effect defines the effect to bind the view projection matrix to
  20281. */
  20282. bindViewProjection(effect: Effect): void;
  20283. /**
  20284. * Specifies if material alpha testing should be turned on for the mesh
  20285. * @param mesh defines the mesh to check
  20286. */
  20287. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20288. /**
  20289. * Processes to execute after binding the material to a mesh
  20290. * @param mesh defines the rendered mesh
  20291. */
  20292. protected _afterBind(mesh?: Mesh): void;
  20293. /**
  20294. * Unbinds the material from the mesh
  20295. */
  20296. unbind(): void;
  20297. /**
  20298. * Gets the active textures from the material
  20299. * @returns an array of textures
  20300. */
  20301. getActiveTextures(): BaseTexture[];
  20302. /**
  20303. * Specifies if the material uses a texture
  20304. * @param texture defines the texture to check against the material
  20305. * @returns a boolean specifying if the material uses the texture
  20306. */
  20307. hasTexture(texture: BaseTexture): boolean;
  20308. /**
  20309. * Makes a duplicate of the material, and gives it a new name
  20310. * @param name defines the new name for the duplicated material
  20311. * @returns the cloned material
  20312. */
  20313. clone(name: string): Nullable<Material>;
  20314. /**
  20315. * Gets the meshes bound to the material
  20316. * @returns an array of meshes bound to the material
  20317. */
  20318. getBindedMeshes(): AbstractMesh[];
  20319. /**
  20320. * Force shader compilation
  20321. * @param mesh defines the mesh associated with this material
  20322. * @param onCompiled defines a function to execute once the material is compiled
  20323. * @param options defines the options to configure the compilation
  20324. */
  20325. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20326. clipPlane: boolean;
  20327. }>): void;
  20328. /**
  20329. * Force shader compilation
  20330. * @param mesh defines the mesh that will use this material
  20331. * @param options defines additional options for compiling the shaders
  20332. * @returns a promise that resolves when the compilation completes
  20333. */
  20334. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20335. clipPlane: boolean;
  20336. }>): Promise<void>;
  20337. private static readonly _AllDirtyCallBack;
  20338. private static readonly _ImageProcessingDirtyCallBack;
  20339. private static readonly _TextureDirtyCallBack;
  20340. private static readonly _FresnelDirtyCallBack;
  20341. private static readonly _MiscDirtyCallBack;
  20342. private static readonly _LightsDirtyCallBack;
  20343. private static readonly _AttributeDirtyCallBack;
  20344. private static _FresnelAndMiscDirtyCallBack;
  20345. private static _TextureAndMiscDirtyCallBack;
  20346. private static readonly _DirtyCallbackArray;
  20347. private static readonly _RunDirtyCallBacks;
  20348. /**
  20349. * Marks a define in the material to indicate that it needs to be re-computed
  20350. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20351. */
  20352. markAsDirty(flag: number): void;
  20353. /**
  20354. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20355. * @param func defines a function which checks material defines against the submeshes
  20356. */
  20357. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20358. /**
  20359. * Indicates that we need to re-calculated for all submeshes
  20360. */
  20361. protected _markAllSubMeshesAsAllDirty(): void;
  20362. /**
  20363. * Indicates that image processing needs to be re-calculated for all submeshes
  20364. */
  20365. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20366. /**
  20367. * Indicates that textures need to be re-calculated for all submeshes
  20368. */
  20369. protected _markAllSubMeshesAsTexturesDirty(): void;
  20370. /**
  20371. * Indicates that fresnel needs to be re-calculated for all submeshes
  20372. */
  20373. protected _markAllSubMeshesAsFresnelDirty(): void;
  20374. /**
  20375. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20376. */
  20377. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20378. /**
  20379. * Indicates that lights need to be re-calculated for all submeshes
  20380. */
  20381. protected _markAllSubMeshesAsLightsDirty(): void;
  20382. /**
  20383. * Indicates that attributes need to be re-calculated for all submeshes
  20384. */
  20385. protected _markAllSubMeshesAsAttributesDirty(): void;
  20386. /**
  20387. * Indicates that misc needs to be re-calculated for all submeshes
  20388. */
  20389. protected _markAllSubMeshesAsMiscDirty(): void;
  20390. /**
  20391. * Indicates that textures and misc need to be re-calculated for all submeshes
  20392. */
  20393. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20394. /**
  20395. * Disposes the material
  20396. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20397. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20398. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20399. */
  20400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20401. /** @hidden */
  20402. private releaseVertexArrayObject;
  20403. /**
  20404. * Serializes this material
  20405. * @returns the serialized material object
  20406. */
  20407. serialize(): any;
  20408. /**
  20409. * Creates a material from parsed material data
  20410. * @param parsedMaterial defines parsed material data
  20411. * @param scene defines the hosting scene
  20412. * @param rootUrl defines the root URL to use to load textures
  20413. * @returns a new material
  20414. */
  20415. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20416. }
  20417. }
  20418. declare module BABYLON {
  20419. /**
  20420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20421. * separate meshes. This can be use to improve performances.
  20422. * @see http://doc.babylonjs.com/how_to/multi_materials
  20423. */
  20424. export class MultiMaterial extends Material {
  20425. private _subMaterials;
  20426. /**
  20427. * Gets or Sets the list of Materials used within the multi material.
  20428. * They need to be ordered according to the submeshes order in the associated mesh
  20429. */
  20430. subMaterials: Nullable<Material>[];
  20431. /**
  20432. * Function used to align with Node.getChildren()
  20433. * @returns the list of Materials used within the multi material
  20434. */
  20435. getChildren(): Nullable<Material>[];
  20436. /**
  20437. * Instantiates a new Multi Material
  20438. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20439. * separate meshes. This can be use to improve performances.
  20440. * @see http://doc.babylonjs.com/how_to/multi_materials
  20441. * @param name Define the name in the scene
  20442. * @param scene Define the scene the material belongs to
  20443. */
  20444. constructor(name: string, scene: Scene);
  20445. private _hookArray;
  20446. /**
  20447. * Get one of the submaterial by its index in the submaterials array
  20448. * @param index The index to look the sub material at
  20449. * @returns The Material if the index has been defined
  20450. */
  20451. getSubMaterial(index: number): Nullable<Material>;
  20452. /**
  20453. * Get the list of active textures for the whole sub materials list.
  20454. * @returns All the textures that will be used during the rendering
  20455. */
  20456. getActiveTextures(): BaseTexture[];
  20457. /**
  20458. * Gets the current class name of the material e.g. "MultiMaterial"
  20459. * Mainly use in serialization.
  20460. * @returns the class name
  20461. */
  20462. getClassName(): string;
  20463. /**
  20464. * Checks if the material is ready to render the requested sub mesh
  20465. * @param mesh Define the mesh the submesh belongs to
  20466. * @param subMesh Define the sub mesh to look readyness for
  20467. * @param useInstances Define whether or not the material is used with instances
  20468. * @returns true if ready, otherwise false
  20469. */
  20470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20471. /**
  20472. * Clones the current material and its related sub materials
  20473. * @param name Define the name of the newly cloned material
  20474. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20475. * @returns the cloned material
  20476. */
  20477. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20478. /**
  20479. * Serializes the materials into a JSON representation.
  20480. * @returns the JSON representation
  20481. */
  20482. serialize(): any;
  20483. /**
  20484. * Dispose the material and release its associated resources
  20485. * @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)
  20486. * @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)
  20487. * @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)
  20488. */
  20489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20490. /**
  20491. * Creates a MultiMaterial from parsed MultiMaterial data.
  20492. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20493. * @param scene defines the hosting scene
  20494. * @returns a new MultiMaterial
  20495. */
  20496. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20497. }
  20498. }
  20499. declare module BABYLON {
  20500. /**
  20501. * Base class for submeshes
  20502. */
  20503. export class BaseSubMesh {
  20504. /** @hidden */
  20505. _materialDefines: Nullable<MaterialDefines>;
  20506. /** @hidden */
  20507. _materialEffect: Nullable<Effect>;
  20508. /**
  20509. * Gets associated effect
  20510. */
  20511. readonly effect: Nullable<Effect>;
  20512. /**
  20513. * Sets associated effect (effect used to render this submesh)
  20514. * @param effect defines the effect to associate with
  20515. * @param defines defines the set of defines used to compile this effect
  20516. */
  20517. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20518. }
  20519. /**
  20520. * Defines a subdivision inside a mesh
  20521. */
  20522. export class SubMesh extends BaseSubMesh implements ICullable {
  20523. /** the material index to use */
  20524. materialIndex: number;
  20525. /** vertex index start */
  20526. verticesStart: number;
  20527. /** vertices count */
  20528. verticesCount: number;
  20529. /** index start */
  20530. indexStart: number;
  20531. /** indices count */
  20532. indexCount: number;
  20533. /** @hidden */
  20534. _linesIndexCount: number;
  20535. private _mesh;
  20536. private _renderingMesh;
  20537. private _boundingInfo;
  20538. private _linesIndexBuffer;
  20539. /** @hidden */
  20540. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20541. /** @hidden */
  20542. _trianglePlanes: Plane[];
  20543. /** @hidden */
  20544. _lastColliderTransformMatrix: Nullable<Matrix>;
  20545. /** @hidden */
  20546. _renderId: number;
  20547. /** @hidden */
  20548. _alphaIndex: number;
  20549. /** @hidden */
  20550. _distanceToCamera: number;
  20551. /** @hidden */
  20552. _id: number;
  20553. private _currentMaterial;
  20554. /**
  20555. * Add a new submesh to a mesh
  20556. * @param materialIndex defines the material index to use
  20557. * @param verticesStart defines vertex index start
  20558. * @param verticesCount defines vertices count
  20559. * @param indexStart defines index start
  20560. * @param indexCount defines indices count
  20561. * @param mesh defines the parent mesh
  20562. * @param renderingMesh defines an optional rendering mesh
  20563. * @param createBoundingBox defines if bounding box should be created for this submesh
  20564. * @returns the new submesh
  20565. */
  20566. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20567. /**
  20568. * Creates a new submesh
  20569. * @param materialIndex defines the material index to use
  20570. * @param verticesStart defines vertex index start
  20571. * @param verticesCount defines vertices count
  20572. * @param indexStart defines index start
  20573. * @param indexCount defines indices count
  20574. * @param mesh defines the parent mesh
  20575. * @param renderingMesh defines an optional rendering mesh
  20576. * @param createBoundingBox defines if bounding box should be created for this submesh
  20577. */
  20578. constructor(
  20579. /** the material index to use */
  20580. materialIndex: number,
  20581. /** vertex index start */
  20582. verticesStart: number,
  20583. /** vertices count */
  20584. verticesCount: number,
  20585. /** index start */
  20586. indexStart: number,
  20587. /** indices count */
  20588. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20589. /**
  20590. * Returns true if this submesh covers the entire parent mesh
  20591. * @ignorenaming
  20592. */
  20593. readonly IsGlobal: boolean;
  20594. /**
  20595. * Returns the submesh BoudingInfo object
  20596. * @returns current bounding info (or mesh's one if the submesh is global)
  20597. */
  20598. getBoundingInfo(): BoundingInfo;
  20599. /**
  20600. * Sets the submesh BoundingInfo
  20601. * @param boundingInfo defines the new bounding info to use
  20602. * @returns the SubMesh
  20603. */
  20604. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20605. /**
  20606. * Returns the mesh of the current submesh
  20607. * @return the parent mesh
  20608. */
  20609. getMesh(): AbstractMesh;
  20610. /**
  20611. * Returns the rendering mesh of the submesh
  20612. * @returns the rendering mesh (could be different from parent mesh)
  20613. */
  20614. getRenderingMesh(): Mesh;
  20615. /**
  20616. * Returns the submesh material
  20617. * @returns null or the current material
  20618. */
  20619. getMaterial(): Nullable<Material>;
  20620. /**
  20621. * Sets a new updated BoundingInfo object to the submesh
  20622. * @param data defines an optional position array to use to determine the bounding info
  20623. * @returns the SubMesh
  20624. */
  20625. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20626. /** @hidden */
  20627. _checkCollision(collider: Collider): boolean;
  20628. /**
  20629. * Updates the submesh BoundingInfo
  20630. * @param world defines the world matrix to use to update the bounding info
  20631. * @returns the submesh
  20632. */
  20633. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20634. /**
  20635. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20636. * @param frustumPlanes defines the frustum planes
  20637. * @returns true if the submesh is intersecting with the frustum
  20638. */
  20639. isInFrustum(frustumPlanes: Plane[]): boolean;
  20640. /**
  20641. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20642. * @param frustumPlanes defines the frustum planes
  20643. * @returns true if the submesh is inside the frustum
  20644. */
  20645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20646. /**
  20647. * Renders the submesh
  20648. * @param enableAlphaMode defines if alpha needs to be used
  20649. * @returns the submesh
  20650. */
  20651. render(enableAlphaMode: boolean): SubMesh;
  20652. /**
  20653. * @hidden
  20654. */
  20655. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20656. /**
  20657. * Checks if the submesh intersects with a ray
  20658. * @param ray defines the ray to test
  20659. * @returns true is the passed ray intersects the submesh bounding box
  20660. */
  20661. canIntersects(ray: Ray): boolean;
  20662. /**
  20663. * Intersects current submesh with a ray
  20664. * @param ray defines the ray to test
  20665. * @param positions defines mesh's positions array
  20666. * @param indices defines mesh's indices array
  20667. * @param fastCheck defines if only bounding info should be used
  20668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20669. * @returns intersection info or null if no intersection
  20670. */
  20671. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20672. /** @hidden */
  20673. private _intersectLines;
  20674. /** @hidden */
  20675. private _intersectUnIndexedLines;
  20676. /** @hidden */
  20677. private _intersectTriangles;
  20678. /** @hidden */
  20679. private _intersectUnIndexedTriangles;
  20680. /** @hidden */
  20681. _rebuild(): void;
  20682. /**
  20683. * Creates a new submesh from the passed mesh
  20684. * @param newMesh defines the new hosting mesh
  20685. * @param newRenderingMesh defines an optional rendering mesh
  20686. * @returns the new submesh
  20687. */
  20688. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20689. /**
  20690. * Release associated resources
  20691. */
  20692. dispose(): void;
  20693. /**
  20694. * Gets the class name
  20695. * @returns the string "SubMesh".
  20696. */
  20697. getClassName(): string;
  20698. /**
  20699. * Creates a new submesh from indices data
  20700. * @param materialIndex the index of the main mesh material
  20701. * @param startIndex the index where to start the copy in the mesh indices array
  20702. * @param indexCount the number of indices to copy then from the startIndex
  20703. * @param mesh the main mesh to create the submesh from
  20704. * @param renderingMesh the optional rendering mesh
  20705. * @returns a new submesh
  20706. */
  20707. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20708. }
  20709. }
  20710. declare module BABYLON {
  20711. /**
  20712. * Class used to represent data loading progression
  20713. */
  20714. export class SceneLoaderFlags {
  20715. private static _ForceFullSceneLoadingForIncremental;
  20716. private static _ShowLoadingScreen;
  20717. private static _CleanBoneMatrixWeights;
  20718. private static _loggingLevel;
  20719. /**
  20720. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20721. */
  20722. static ForceFullSceneLoadingForIncremental: boolean;
  20723. /**
  20724. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20725. */
  20726. static ShowLoadingScreen: boolean;
  20727. /**
  20728. * Defines the current logging level (while loading the scene)
  20729. * @ignorenaming
  20730. */
  20731. static loggingLevel: number;
  20732. /**
  20733. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20734. */
  20735. static CleanBoneMatrixWeights: boolean;
  20736. }
  20737. }
  20738. declare module BABYLON {
  20739. /**
  20740. * Class used to store geometry data (vertex buffers + index buffer)
  20741. */
  20742. export class Geometry implements IGetSetVerticesData {
  20743. /**
  20744. * Gets or sets the ID of the geometry
  20745. */
  20746. id: string;
  20747. /**
  20748. * Gets or sets the unique ID of the geometry
  20749. */
  20750. uniqueId: number;
  20751. /**
  20752. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20753. */
  20754. delayLoadState: number;
  20755. /**
  20756. * Gets the file containing the data to load when running in delay load state
  20757. */
  20758. delayLoadingFile: Nullable<string>;
  20759. /**
  20760. * Callback called when the geometry is updated
  20761. */
  20762. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20763. private _scene;
  20764. private _engine;
  20765. private _meshes;
  20766. private _totalVertices;
  20767. /** @hidden */
  20768. _indices: IndicesArray;
  20769. /** @hidden */
  20770. _vertexBuffers: {
  20771. [key: string]: VertexBuffer;
  20772. };
  20773. private _isDisposed;
  20774. private _extend;
  20775. private _boundingBias;
  20776. /** @hidden */
  20777. _delayInfo: Array<string>;
  20778. private _indexBuffer;
  20779. private _indexBufferIsUpdatable;
  20780. /** @hidden */
  20781. _boundingInfo: Nullable<BoundingInfo>;
  20782. /** @hidden */
  20783. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20784. /** @hidden */
  20785. _softwareSkinningFrameId: number;
  20786. private _vertexArrayObjects;
  20787. private _updatable;
  20788. /** @hidden */
  20789. _positions: Nullable<Vector3[]>;
  20790. /**
  20791. * 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
  20792. */
  20793. /**
  20794. * 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
  20795. */
  20796. boundingBias: Vector2;
  20797. /**
  20798. * Static function used to attach a new empty geometry to a mesh
  20799. * @param mesh defines the mesh to attach the geometry to
  20800. * @returns the new Geometry
  20801. */
  20802. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20803. /**
  20804. * Creates a new geometry
  20805. * @param id defines the unique ID
  20806. * @param scene defines the hosting scene
  20807. * @param vertexData defines the VertexData used to get geometry data
  20808. * @param updatable defines if geometry must be updatable (false by default)
  20809. * @param mesh defines the mesh that will be associated with the geometry
  20810. */
  20811. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20812. /**
  20813. * Gets the current extend of the geometry
  20814. */
  20815. readonly extend: {
  20816. minimum: Vector3;
  20817. maximum: Vector3;
  20818. };
  20819. /**
  20820. * Gets the hosting scene
  20821. * @returns the hosting Scene
  20822. */
  20823. getScene(): Scene;
  20824. /**
  20825. * Gets the hosting engine
  20826. * @returns the hosting Engine
  20827. */
  20828. getEngine(): Engine;
  20829. /**
  20830. * Defines if the geometry is ready to use
  20831. * @returns true if the geometry is ready to be used
  20832. */
  20833. isReady(): boolean;
  20834. /**
  20835. * Gets a value indicating that the geometry should not be serialized
  20836. */
  20837. readonly doNotSerialize: boolean;
  20838. /** @hidden */
  20839. _rebuild(): void;
  20840. /**
  20841. * Affects all geometry data in one call
  20842. * @param vertexData defines the geometry data
  20843. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20844. */
  20845. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20846. /**
  20847. * Set specific vertex data
  20848. * @param kind defines the data kind (Position, normal, etc...)
  20849. * @param data defines the vertex data to use
  20850. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20851. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20852. */
  20853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20854. /**
  20855. * Removes a specific vertex data
  20856. * @param kind defines the data kind (Position, normal, etc...)
  20857. */
  20858. removeVerticesData(kind: string): void;
  20859. /**
  20860. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20861. * @param buffer defines the vertex buffer to use
  20862. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20863. */
  20864. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20865. /**
  20866. * Update a specific vertex buffer
  20867. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20868. * It will do nothing if the buffer is not updatable
  20869. * @param kind defines the data kind (Position, normal, etc...)
  20870. * @param data defines the data to use
  20871. * @param offset defines the offset in the target buffer where to store the data
  20872. * @param useBytes set to true if the offset is in bytes
  20873. */
  20874. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20875. /**
  20876. * Update a specific vertex buffer
  20877. * This function will create a new buffer if the current one is not updatable
  20878. * @param kind defines the data kind (Position, normal, etc...)
  20879. * @param data defines the data to use
  20880. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20881. */
  20882. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20883. private _updateBoundingInfo;
  20884. /** @hidden */
  20885. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20886. /**
  20887. * Gets total number of vertices
  20888. * @returns the total number of vertices
  20889. */
  20890. getTotalVertices(): number;
  20891. /**
  20892. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20893. * @param kind defines the data kind (Position, normal, etc...)
  20894. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20896. * @returns a float array containing vertex data
  20897. */
  20898. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20899. /**
  20900. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20901. * @param kind defines the data kind (Position, normal, etc...)
  20902. * @returns true if the vertex buffer with the specified kind is updatable
  20903. */
  20904. isVertexBufferUpdatable(kind: string): boolean;
  20905. /**
  20906. * Gets a specific vertex buffer
  20907. * @param kind defines the data kind (Position, normal, etc...)
  20908. * @returns a VertexBuffer
  20909. */
  20910. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20911. /**
  20912. * Returns all vertex buffers
  20913. * @return an object holding all vertex buffers indexed by kind
  20914. */
  20915. getVertexBuffers(): Nullable<{
  20916. [key: string]: VertexBuffer;
  20917. }>;
  20918. /**
  20919. * Gets a boolean indicating if specific vertex buffer is present
  20920. * @param kind defines the data kind (Position, normal, etc...)
  20921. * @returns true if data is present
  20922. */
  20923. isVerticesDataPresent(kind: string): boolean;
  20924. /**
  20925. * Gets a list of all attached data kinds (Position, normal, etc...)
  20926. * @returns a list of string containing all kinds
  20927. */
  20928. getVerticesDataKinds(): string[];
  20929. /**
  20930. * Update index buffer
  20931. * @param indices defines the indices to store in the index buffer
  20932. * @param offset defines the offset in the target buffer where to store the data
  20933. * @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)
  20934. */
  20935. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20936. /**
  20937. * Creates a new index buffer
  20938. * @param indices defines the indices to store in the index buffer
  20939. * @param totalVertices defines the total number of vertices (could be null)
  20940. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20941. */
  20942. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20943. /**
  20944. * Return the total number of indices
  20945. * @returns the total number of indices
  20946. */
  20947. getTotalIndices(): number;
  20948. /**
  20949. * Gets the index buffer array
  20950. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20951. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20952. * @returns the index buffer array
  20953. */
  20954. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20955. /**
  20956. * Gets the index buffer
  20957. * @return the index buffer
  20958. */
  20959. getIndexBuffer(): Nullable<DataBuffer>;
  20960. /** @hidden */
  20961. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20962. /**
  20963. * Release the associated resources for a specific mesh
  20964. * @param mesh defines the source mesh
  20965. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20966. */
  20967. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20968. /**
  20969. * Apply current geometry to a given mesh
  20970. * @param mesh defines the mesh to apply geometry to
  20971. */
  20972. applyToMesh(mesh: Mesh): void;
  20973. private _updateExtend;
  20974. private _applyToMesh;
  20975. private notifyUpdate;
  20976. /**
  20977. * Load the geometry if it was flagged as delay loaded
  20978. * @param scene defines the hosting scene
  20979. * @param onLoaded defines a callback called when the geometry is loaded
  20980. */
  20981. load(scene: Scene, onLoaded?: () => void): void;
  20982. private _queueLoad;
  20983. /**
  20984. * Invert the geometry to move from a right handed system to a left handed one.
  20985. */
  20986. toLeftHanded(): void;
  20987. /** @hidden */
  20988. _resetPointsArrayCache(): void;
  20989. /** @hidden */
  20990. _generatePointsArray(): boolean;
  20991. /**
  20992. * Gets a value indicating if the geometry is disposed
  20993. * @returns true if the geometry was disposed
  20994. */
  20995. isDisposed(): boolean;
  20996. private _disposeVertexArrayObjects;
  20997. /**
  20998. * Free all associated resources
  20999. */
  21000. dispose(): void;
  21001. /**
  21002. * Clone the current geometry into a new geometry
  21003. * @param id defines the unique ID of the new geometry
  21004. * @returns a new geometry object
  21005. */
  21006. copy(id: string): Geometry;
  21007. /**
  21008. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21009. * @return a JSON representation of the current geometry data (without the vertices data)
  21010. */
  21011. serialize(): any;
  21012. private toNumberArray;
  21013. /**
  21014. * Serialize all vertices data into a JSON oject
  21015. * @returns a JSON representation of the current geometry data
  21016. */
  21017. serializeVerticeData(): any;
  21018. /**
  21019. * Extracts a clone of a mesh geometry
  21020. * @param mesh defines the source mesh
  21021. * @param id defines the unique ID of the new geometry object
  21022. * @returns the new geometry object
  21023. */
  21024. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21025. /**
  21026. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21027. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21028. * Be aware Math.random() could cause collisions, but:
  21029. * "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"
  21030. * @returns a string containing a new GUID
  21031. */
  21032. static RandomId(): string;
  21033. /** @hidden */
  21034. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21035. private static _CleanMatricesWeights;
  21036. /**
  21037. * Create a new geometry from persisted data (Using .babylon file format)
  21038. * @param parsedVertexData defines the persisted data
  21039. * @param scene defines the hosting scene
  21040. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21041. * @returns the new geometry object
  21042. */
  21043. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21044. }
  21045. }
  21046. declare module BABYLON {
  21047. /**
  21048. * Define an interface for all classes that will get and set the data on vertices
  21049. */
  21050. export interface IGetSetVerticesData {
  21051. /**
  21052. * Gets a boolean indicating if specific vertex data is present
  21053. * @param kind defines the vertex data kind to use
  21054. * @returns true is data kind is present
  21055. */
  21056. isVerticesDataPresent(kind: string): boolean;
  21057. /**
  21058. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21059. * @param kind defines the data kind (Position, normal, etc...)
  21060. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21062. * @returns a float array containing vertex data
  21063. */
  21064. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21065. /**
  21066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21067. * @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.
  21068. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21069. * @returns the indices array or an empty array if the mesh has no geometry
  21070. */
  21071. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21072. /**
  21073. * Set specific vertex data
  21074. * @param kind defines the data kind (Position, normal, etc...)
  21075. * @param data defines the vertex data to use
  21076. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21077. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21078. */
  21079. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21080. /**
  21081. * Update a specific associated vertex buffer
  21082. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21083. * - VertexBuffer.PositionKind
  21084. * - VertexBuffer.UVKind
  21085. * - VertexBuffer.UV2Kind
  21086. * - VertexBuffer.UV3Kind
  21087. * - VertexBuffer.UV4Kind
  21088. * - VertexBuffer.UV5Kind
  21089. * - VertexBuffer.UV6Kind
  21090. * - VertexBuffer.ColorKind
  21091. * - VertexBuffer.MatricesIndicesKind
  21092. * - VertexBuffer.MatricesIndicesExtraKind
  21093. * - VertexBuffer.MatricesWeightsKind
  21094. * - VertexBuffer.MatricesWeightsExtraKind
  21095. * @param data defines the data source
  21096. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21097. * @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)
  21098. */
  21099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21100. /**
  21101. * Creates a new index buffer
  21102. * @param indices defines the indices to store in the index buffer
  21103. * @param totalVertices defines the total number of vertices (could be null)
  21104. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21105. */
  21106. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21107. }
  21108. /**
  21109. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21110. */
  21111. export class VertexData {
  21112. /**
  21113. * Mesh side orientation : usually the external or front surface
  21114. */
  21115. static readonly FRONTSIDE: number;
  21116. /**
  21117. * Mesh side orientation : usually the internal or back surface
  21118. */
  21119. static readonly BACKSIDE: number;
  21120. /**
  21121. * Mesh side orientation : both internal and external or front and back surfaces
  21122. */
  21123. static readonly DOUBLESIDE: number;
  21124. /**
  21125. * Mesh side orientation : by default, `FRONTSIDE`
  21126. */
  21127. static readonly DEFAULTSIDE: number;
  21128. /**
  21129. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21130. */
  21131. positions: Nullable<FloatArray>;
  21132. /**
  21133. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21134. */
  21135. normals: Nullable<FloatArray>;
  21136. /**
  21137. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21138. */
  21139. tangents: Nullable<FloatArray>;
  21140. /**
  21141. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21142. */
  21143. uvs: Nullable<FloatArray>;
  21144. /**
  21145. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21146. */
  21147. uvs2: Nullable<FloatArray>;
  21148. /**
  21149. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21150. */
  21151. uvs3: Nullable<FloatArray>;
  21152. /**
  21153. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21154. */
  21155. uvs4: Nullable<FloatArray>;
  21156. /**
  21157. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21158. */
  21159. uvs5: Nullable<FloatArray>;
  21160. /**
  21161. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21162. */
  21163. uvs6: Nullable<FloatArray>;
  21164. /**
  21165. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21166. */
  21167. colors: Nullable<FloatArray>;
  21168. /**
  21169. * 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).
  21170. */
  21171. matricesIndices: Nullable<FloatArray>;
  21172. /**
  21173. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21174. */
  21175. matricesWeights: Nullable<FloatArray>;
  21176. /**
  21177. * An array extending the number of possible indices
  21178. */
  21179. matricesIndicesExtra: Nullable<FloatArray>;
  21180. /**
  21181. * An array extending the number of possible weights when the number of indices is extended
  21182. */
  21183. matricesWeightsExtra: Nullable<FloatArray>;
  21184. /**
  21185. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21186. */
  21187. indices: Nullable<IndicesArray>;
  21188. /**
  21189. * Uses the passed data array to set the set the values for the specified kind of data
  21190. * @param data a linear array of floating numbers
  21191. * @param kind the type of data that is being set, eg positions, colors etc
  21192. */
  21193. set(data: FloatArray, kind: string): void;
  21194. /**
  21195. * Associates the vertexData to the passed Mesh.
  21196. * Sets it as updatable or not (default `false`)
  21197. * @param mesh the mesh the vertexData is applied to
  21198. * @param updatable when used and having the value true allows new data to update the vertexData
  21199. * @returns the VertexData
  21200. */
  21201. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21202. /**
  21203. * Associates the vertexData to the passed Geometry.
  21204. * Sets it as updatable or not (default `false`)
  21205. * @param geometry the geometry the vertexData is applied to
  21206. * @param updatable when used and having the value true allows new data to update the vertexData
  21207. * @returns VertexData
  21208. */
  21209. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21210. /**
  21211. * Updates the associated mesh
  21212. * @param mesh the mesh to be updated
  21213. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21214. * @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
  21215. * @returns VertexData
  21216. */
  21217. updateMesh(mesh: Mesh): VertexData;
  21218. /**
  21219. * Updates the associated geometry
  21220. * @param geometry the geometry to be updated
  21221. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21222. * @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
  21223. * @returns VertexData.
  21224. */
  21225. updateGeometry(geometry: Geometry): VertexData;
  21226. private _applyTo;
  21227. private _update;
  21228. /**
  21229. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21230. * @param matrix the transforming matrix
  21231. * @returns the VertexData
  21232. */
  21233. transform(matrix: Matrix): VertexData;
  21234. /**
  21235. * Merges the passed VertexData into the current one
  21236. * @param other the VertexData to be merged into the current one
  21237. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21238. * @returns the modified VertexData
  21239. */
  21240. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21241. private _mergeElement;
  21242. private _validate;
  21243. /**
  21244. * Serializes the VertexData
  21245. * @returns a serialized object
  21246. */
  21247. serialize(): any;
  21248. /**
  21249. * Extracts the vertexData from a mesh
  21250. * @param mesh the mesh from which to extract the VertexData
  21251. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21252. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21253. * @returns the object VertexData associated to the passed mesh
  21254. */
  21255. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21256. /**
  21257. * Extracts the vertexData from the geometry
  21258. * @param geometry the geometry from which to extract the VertexData
  21259. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21260. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21261. * @returns the object VertexData associated to the passed mesh
  21262. */
  21263. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21264. private static _ExtractFrom;
  21265. /**
  21266. * Creates the VertexData for a Ribbon
  21267. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21268. * * pathArray array of paths, each of which an array of successive Vector3
  21269. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21270. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21271. * * 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
  21272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21273. * * 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)
  21274. * * 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)
  21275. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21276. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21277. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21278. * @returns the VertexData of the ribbon
  21279. */
  21280. static CreateRibbon(options: {
  21281. pathArray: Vector3[][];
  21282. closeArray?: boolean;
  21283. closePath?: boolean;
  21284. offset?: number;
  21285. sideOrientation?: number;
  21286. frontUVs?: Vector4;
  21287. backUVs?: Vector4;
  21288. invertUV?: boolean;
  21289. uvs?: Vector2[];
  21290. colors?: Color4[];
  21291. }): VertexData;
  21292. /**
  21293. * Creates the VertexData for a box
  21294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21295. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21296. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21297. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21298. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21299. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21300. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21302. * * 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)
  21303. * * 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)
  21304. * @returns the VertexData of the box
  21305. */
  21306. static CreateBox(options: {
  21307. size?: number;
  21308. width?: number;
  21309. height?: number;
  21310. depth?: number;
  21311. faceUV?: Vector4[];
  21312. faceColors?: Color4[];
  21313. sideOrientation?: number;
  21314. frontUVs?: Vector4;
  21315. backUVs?: Vector4;
  21316. }): VertexData;
  21317. /**
  21318. * Creates the VertexData for a tiled box
  21319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21320. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21321. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21322. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21324. * @returns the VertexData of the box
  21325. */
  21326. static CreateTiledBox(options: {
  21327. pattern?: number;
  21328. width?: number;
  21329. height?: number;
  21330. depth?: number;
  21331. tileSize?: number;
  21332. tileWidth?: number;
  21333. tileHeight?: number;
  21334. alignHorizontal?: number;
  21335. alignVertical?: number;
  21336. faceUV?: Vector4[];
  21337. faceColors?: Color4[];
  21338. sideOrientation?: number;
  21339. }): VertexData;
  21340. /**
  21341. * Creates the VertexData for a tiled plane
  21342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21343. * * pattern a limited pattern arrangement depending on the number
  21344. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21345. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21346. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21348. * * 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)
  21349. * * 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)
  21350. * @returns the VertexData of the tiled plane
  21351. */
  21352. static CreateTiledPlane(options: {
  21353. pattern?: number;
  21354. tileSize?: number;
  21355. tileWidth?: number;
  21356. tileHeight?: number;
  21357. size?: number;
  21358. width?: number;
  21359. height?: number;
  21360. alignHorizontal?: number;
  21361. alignVertical?: number;
  21362. sideOrientation?: number;
  21363. frontUVs?: Vector4;
  21364. backUVs?: Vector4;
  21365. }): VertexData;
  21366. /**
  21367. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21369. * * segments sets the number of horizontal strips optional, default 32
  21370. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21371. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21372. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21373. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21374. * * 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
  21375. * * 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
  21376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21377. * * 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)
  21378. * * 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)
  21379. * @returns the VertexData of the ellipsoid
  21380. */
  21381. static CreateSphere(options: {
  21382. segments?: number;
  21383. diameter?: number;
  21384. diameterX?: number;
  21385. diameterY?: number;
  21386. diameterZ?: number;
  21387. arc?: number;
  21388. slice?: number;
  21389. sideOrientation?: number;
  21390. frontUVs?: Vector4;
  21391. backUVs?: Vector4;
  21392. }): VertexData;
  21393. /**
  21394. * Creates the VertexData for a cylinder, cone or prism
  21395. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21396. * * height sets the height (y direction) of the cylinder, optional, default 2
  21397. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21398. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21399. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21400. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21401. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21402. * * 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
  21403. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21404. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21405. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21406. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21408. * * 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)
  21409. * * 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)
  21410. * @returns the VertexData of the cylinder, cone or prism
  21411. */
  21412. static CreateCylinder(options: {
  21413. height?: number;
  21414. diameterTop?: number;
  21415. diameterBottom?: number;
  21416. diameter?: number;
  21417. tessellation?: number;
  21418. subdivisions?: number;
  21419. arc?: number;
  21420. faceColors?: Color4[];
  21421. faceUV?: Vector4[];
  21422. hasRings?: boolean;
  21423. enclose?: boolean;
  21424. sideOrientation?: number;
  21425. frontUVs?: Vector4;
  21426. backUVs?: Vector4;
  21427. }): VertexData;
  21428. /**
  21429. * Creates the VertexData for a torus
  21430. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21431. * * diameter the diameter of the torus, optional default 1
  21432. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21433. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21435. * * 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)
  21436. * * 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)
  21437. * @returns the VertexData of the torus
  21438. */
  21439. static CreateTorus(options: {
  21440. diameter?: number;
  21441. thickness?: number;
  21442. tessellation?: number;
  21443. sideOrientation?: number;
  21444. frontUVs?: Vector4;
  21445. backUVs?: Vector4;
  21446. }): VertexData;
  21447. /**
  21448. * Creates the VertexData of the LineSystem
  21449. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21450. * - lines an array of lines, each line being an array of successive Vector3
  21451. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21452. * @returns the VertexData of the LineSystem
  21453. */
  21454. static CreateLineSystem(options: {
  21455. lines: Vector3[][];
  21456. colors?: Nullable<Color4[][]>;
  21457. }): VertexData;
  21458. /**
  21459. * Create the VertexData for a DashedLines
  21460. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21461. * - points an array successive Vector3
  21462. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21463. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21464. * - dashNb the intended total number of dashes, optional, default 200
  21465. * @returns the VertexData for the DashedLines
  21466. */
  21467. static CreateDashedLines(options: {
  21468. points: Vector3[];
  21469. dashSize?: number;
  21470. gapSize?: number;
  21471. dashNb?: number;
  21472. }): VertexData;
  21473. /**
  21474. * Creates the VertexData for a Ground
  21475. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21476. * - width the width (x direction) of the ground, optional, default 1
  21477. * - height the height (z direction) of the ground, optional, default 1
  21478. * - subdivisions the number of subdivisions per side, optional, default 1
  21479. * @returns the VertexData of the Ground
  21480. */
  21481. static CreateGround(options: {
  21482. width?: number;
  21483. height?: number;
  21484. subdivisions?: number;
  21485. subdivisionsX?: number;
  21486. subdivisionsY?: number;
  21487. }): VertexData;
  21488. /**
  21489. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21490. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21491. * * xmin the ground minimum X coordinate, optional, default -1
  21492. * * zmin the ground minimum Z coordinate, optional, default -1
  21493. * * xmax the ground maximum X coordinate, optional, default 1
  21494. * * zmax the ground maximum Z coordinate, optional, default 1
  21495. * * 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}
  21496. * * 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}
  21497. * @returns the VertexData of the TiledGround
  21498. */
  21499. static CreateTiledGround(options: {
  21500. xmin: number;
  21501. zmin: number;
  21502. xmax: number;
  21503. zmax: number;
  21504. subdivisions?: {
  21505. w: number;
  21506. h: number;
  21507. };
  21508. precision?: {
  21509. w: number;
  21510. h: number;
  21511. };
  21512. }): VertexData;
  21513. /**
  21514. * Creates the VertexData of the Ground designed from a heightmap
  21515. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21516. * * width the width (x direction) of the ground
  21517. * * height the height (z direction) of the ground
  21518. * * subdivisions the number of subdivisions per side
  21519. * * minHeight the minimum altitude on the ground, optional, default 0
  21520. * * maxHeight the maximum altitude on the ground, optional default 1
  21521. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21522. * * buffer the array holding the image color data
  21523. * * bufferWidth the width of image
  21524. * * bufferHeight the height of image
  21525. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21526. * @returns the VertexData of the Ground designed from a heightmap
  21527. */
  21528. static CreateGroundFromHeightMap(options: {
  21529. width: number;
  21530. height: number;
  21531. subdivisions: number;
  21532. minHeight: number;
  21533. maxHeight: number;
  21534. colorFilter: Color3;
  21535. buffer: Uint8Array;
  21536. bufferWidth: number;
  21537. bufferHeight: number;
  21538. alphaFilter: number;
  21539. }): VertexData;
  21540. /**
  21541. * Creates the VertexData for a Plane
  21542. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21543. * * size sets the width and height of the plane to the value of size, optional default 1
  21544. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21545. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21547. * * 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)
  21548. * * 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)
  21549. * @returns the VertexData of the box
  21550. */
  21551. static CreatePlane(options: {
  21552. size?: number;
  21553. width?: number;
  21554. height?: number;
  21555. sideOrientation?: number;
  21556. frontUVs?: Vector4;
  21557. backUVs?: Vector4;
  21558. }): VertexData;
  21559. /**
  21560. * Creates the VertexData of the Disc or regular Polygon
  21561. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21562. * * radius the radius of the disc, optional default 0.5
  21563. * * tessellation the number of polygon sides, optional, default 64
  21564. * * 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
  21565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21566. * * 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)
  21567. * * 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)
  21568. * @returns the VertexData of the box
  21569. */
  21570. static CreateDisc(options: {
  21571. radius?: number;
  21572. tessellation?: number;
  21573. arc?: number;
  21574. sideOrientation?: number;
  21575. frontUVs?: Vector4;
  21576. backUVs?: Vector4;
  21577. }): VertexData;
  21578. /**
  21579. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21580. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21581. * @param polygon a mesh built from polygonTriangulation.build()
  21582. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21583. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21584. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21585. * @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)
  21586. * @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)
  21587. * @returns the VertexData of the Polygon
  21588. */
  21589. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21590. /**
  21591. * Creates the VertexData of the IcoSphere
  21592. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21593. * * radius the radius of the IcoSphere, optional default 1
  21594. * * radiusX allows stretching in the x direction, optional, default radius
  21595. * * radiusY allows stretching in the y direction, optional, default radius
  21596. * * radiusZ allows stretching in the z direction, optional, default radius
  21597. * * flat when true creates a flat shaded mesh, optional, default true
  21598. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21600. * * 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)
  21601. * * 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)
  21602. * @returns the VertexData of the IcoSphere
  21603. */
  21604. static CreateIcoSphere(options: {
  21605. radius?: number;
  21606. radiusX?: number;
  21607. radiusY?: number;
  21608. radiusZ?: number;
  21609. flat?: boolean;
  21610. subdivisions?: number;
  21611. sideOrientation?: number;
  21612. frontUVs?: Vector4;
  21613. backUVs?: Vector4;
  21614. }): VertexData;
  21615. /**
  21616. * Creates the VertexData for a Polyhedron
  21617. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21618. * * type provided types are:
  21619. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21620. * * 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)
  21621. * * size the size of the IcoSphere, optional default 1
  21622. * * sizeX allows stretching in the x direction, optional, default size
  21623. * * sizeY allows stretching in the y direction, optional, default size
  21624. * * sizeZ allows stretching in the z direction, optional, default size
  21625. * * 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
  21626. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21627. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21628. * * flat when true creates a flat shaded mesh, optional, default true
  21629. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21631. * * 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)
  21632. * * 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)
  21633. * @returns the VertexData of the Polyhedron
  21634. */
  21635. static CreatePolyhedron(options: {
  21636. type?: number;
  21637. size?: number;
  21638. sizeX?: number;
  21639. sizeY?: number;
  21640. sizeZ?: number;
  21641. custom?: any;
  21642. faceUV?: Vector4[];
  21643. faceColors?: Color4[];
  21644. flat?: boolean;
  21645. sideOrientation?: number;
  21646. frontUVs?: Vector4;
  21647. backUVs?: Vector4;
  21648. }): VertexData;
  21649. /**
  21650. * Creates the VertexData for a TorusKnot
  21651. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21652. * * radius the radius of the torus knot, optional, default 2
  21653. * * tube the thickness of the tube, optional, default 0.5
  21654. * * radialSegments the number of sides on each tube segments, optional, default 32
  21655. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21656. * * p the number of windings around the z axis, optional, default 2
  21657. * * q the number of windings around the x axis, optional, default 3
  21658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21659. * * 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)
  21660. * * 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)
  21661. * @returns the VertexData of the Torus Knot
  21662. */
  21663. static CreateTorusKnot(options: {
  21664. radius?: number;
  21665. tube?: number;
  21666. radialSegments?: number;
  21667. tubularSegments?: number;
  21668. p?: number;
  21669. q?: number;
  21670. sideOrientation?: number;
  21671. frontUVs?: Vector4;
  21672. backUVs?: Vector4;
  21673. }): VertexData;
  21674. /**
  21675. * Compute normals for given positions and indices
  21676. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21677. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21678. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21679. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21680. * * facetNormals : optional array of facet normals (vector3)
  21681. * * facetPositions : optional array of facet positions (vector3)
  21682. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21683. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21684. * * bInfo : optional bounding info, required for facetPartitioning computation
  21685. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21686. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21687. * * useRightHandedSystem: optional boolean to for right handed system computation
  21688. * * depthSort : optional boolean to enable the facet depth sort computation
  21689. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21690. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21691. */
  21692. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21693. facetNormals?: any;
  21694. facetPositions?: any;
  21695. facetPartitioning?: any;
  21696. ratio?: number;
  21697. bInfo?: any;
  21698. bbSize?: Vector3;
  21699. subDiv?: any;
  21700. useRightHandedSystem?: boolean;
  21701. depthSort?: boolean;
  21702. distanceTo?: Vector3;
  21703. depthSortedFacets?: any;
  21704. }): void;
  21705. /** @hidden */
  21706. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21707. /**
  21708. * Applies VertexData created from the imported parameters to the geometry
  21709. * @param parsedVertexData the parsed data from an imported file
  21710. * @param geometry the geometry to apply the VertexData to
  21711. */
  21712. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21713. }
  21714. }
  21715. declare module BABYLON {
  21716. /**
  21717. * Defines a target to use with MorphTargetManager
  21718. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21719. */
  21720. export class MorphTarget implements IAnimatable {
  21721. /** defines the name of the target */
  21722. name: string;
  21723. /**
  21724. * Gets or sets the list of animations
  21725. */
  21726. animations: Animation[];
  21727. private _scene;
  21728. private _positions;
  21729. private _normals;
  21730. private _tangents;
  21731. private _uvs;
  21732. private _influence;
  21733. /**
  21734. * Observable raised when the influence changes
  21735. */
  21736. onInfluenceChanged: Observable<boolean>;
  21737. /** @hidden */
  21738. _onDataLayoutChanged: Observable<void>;
  21739. /**
  21740. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21741. */
  21742. influence: number;
  21743. /**
  21744. * Gets or sets the id of the morph Target
  21745. */
  21746. id: string;
  21747. private _animationPropertiesOverride;
  21748. /**
  21749. * Gets or sets the animation properties override
  21750. */
  21751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21752. /**
  21753. * Creates a new MorphTarget
  21754. * @param name defines the name of the target
  21755. * @param influence defines the influence to use
  21756. * @param scene defines the scene the morphtarget belongs to
  21757. */
  21758. constructor(
  21759. /** defines the name of the target */
  21760. name: string, influence?: number, scene?: Nullable<Scene>);
  21761. /**
  21762. * Gets a boolean defining if the target contains position data
  21763. */
  21764. readonly hasPositions: boolean;
  21765. /**
  21766. * Gets a boolean defining if the target contains normal data
  21767. */
  21768. readonly hasNormals: boolean;
  21769. /**
  21770. * Gets a boolean defining if the target contains tangent data
  21771. */
  21772. readonly hasTangents: boolean;
  21773. /**
  21774. * Gets a boolean defining if the target contains texture coordinates data
  21775. */
  21776. readonly hasUVs: boolean;
  21777. /**
  21778. * Affects position data to this target
  21779. * @param data defines the position data to use
  21780. */
  21781. setPositions(data: Nullable<FloatArray>): void;
  21782. /**
  21783. * Gets the position data stored in this target
  21784. * @returns a FloatArray containing the position data (or null if not present)
  21785. */
  21786. getPositions(): Nullable<FloatArray>;
  21787. /**
  21788. * Affects normal data to this target
  21789. * @param data defines the normal data to use
  21790. */
  21791. setNormals(data: Nullable<FloatArray>): void;
  21792. /**
  21793. * Gets the normal data stored in this target
  21794. * @returns a FloatArray containing the normal data (or null if not present)
  21795. */
  21796. getNormals(): Nullable<FloatArray>;
  21797. /**
  21798. * Affects tangent data to this target
  21799. * @param data defines the tangent data to use
  21800. */
  21801. setTangents(data: Nullable<FloatArray>): void;
  21802. /**
  21803. * Gets the tangent data stored in this target
  21804. * @returns a FloatArray containing the tangent data (or null if not present)
  21805. */
  21806. getTangents(): Nullable<FloatArray>;
  21807. /**
  21808. * Affects texture coordinates data to this target
  21809. * @param data defines the texture coordinates data to use
  21810. */
  21811. setUVs(data: Nullable<FloatArray>): void;
  21812. /**
  21813. * Gets the texture coordinates data stored in this target
  21814. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21815. */
  21816. getUVs(): Nullable<FloatArray>;
  21817. /**
  21818. * Serializes the current target into a Serialization object
  21819. * @returns the serialized object
  21820. */
  21821. serialize(): any;
  21822. /**
  21823. * Returns the string "MorphTarget"
  21824. * @returns "MorphTarget"
  21825. */
  21826. getClassName(): string;
  21827. /**
  21828. * Creates a new target from serialized data
  21829. * @param serializationObject defines the serialized data to use
  21830. * @returns a new MorphTarget
  21831. */
  21832. static Parse(serializationObject: any): MorphTarget;
  21833. /**
  21834. * Creates a MorphTarget from mesh data
  21835. * @param mesh defines the source mesh
  21836. * @param name defines the name to use for the new target
  21837. * @param influence defines the influence to attach to the target
  21838. * @returns a new MorphTarget
  21839. */
  21840. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21841. }
  21842. }
  21843. declare module BABYLON {
  21844. /**
  21845. * This class is used to deform meshes using morphing between different targets
  21846. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21847. */
  21848. export class MorphTargetManager {
  21849. private _targets;
  21850. private _targetInfluenceChangedObservers;
  21851. private _targetDataLayoutChangedObservers;
  21852. private _activeTargets;
  21853. private _scene;
  21854. private _influences;
  21855. private _supportsNormals;
  21856. private _supportsTangents;
  21857. private _supportsUVs;
  21858. private _vertexCount;
  21859. private _uniqueId;
  21860. private _tempInfluences;
  21861. /**
  21862. * Gets or sets a boolean indicating if normals must be morphed
  21863. */
  21864. enableNormalMorphing: boolean;
  21865. /**
  21866. * Gets or sets a boolean indicating if tangents must be morphed
  21867. */
  21868. enableTangentMorphing: boolean;
  21869. /**
  21870. * Gets or sets a boolean indicating if UV must be morphed
  21871. */
  21872. enableUVMorphing: boolean;
  21873. /**
  21874. * Creates a new MorphTargetManager
  21875. * @param scene defines the current scene
  21876. */
  21877. constructor(scene?: Nullable<Scene>);
  21878. /**
  21879. * Gets the unique ID of this manager
  21880. */
  21881. readonly uniqueId: number;
  21882. /**
  21883. * Gets the number of vertices handled by this manager
  21884. */
  21885. readonly vertexCount: number;
  21886. /**
  21887. * Gets a boolean indicating if this manager supports morphing of normals
  21888. */
  21889. readonly supportsNormals: boolean;
  21890. /**
  21891. * Gets a boolean indicating if this manager supports morphing of tangents
  21892. */
  21893. readonly supportsTangents: boolean;
  21894. /**
  21895. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21896. */
  21897. readonly supportsUVs: boolean;
  21898. /**
  21899. * Gets the number of targets stored in this manager
  21900. */
  21901. readonly numTargets: number;
  21902. /**
  21903. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21904. */
  21905. readonly numInfluencers: number;
  21906. /**
  21907. * Gets the list of influences (one per target)
  21908. */
  21909. readonly influences: Float32Array;
  21910. /**
  21911. * Gets the active target at specified index. An active target is a target with an influence > 0
  21912. * @param index defines the index to check
  21913. * @returns the requested target
  21914. */
  21915. getActiveTarget(index: number): MorphTarget;
  21916. /**
  21917. * Gets the target at specified index
  21918. * @param index defines the index to check
  21919. * @returns the requested target
  21920. */
  21921. getTarget(index: number): MorphTarget;
  21922. /**
  21923. * Add a new target to this manager
  21924. * @param target defines the target to add
  21925. */
  21926. addTarget(target: MorphTarget): void;
  21927. /**
  21928. * Removes a target from the manager
  21929. * @param target defines the target to remove
  21930. */
  21931. removeTarget(target: MorphTarget): void;
  21932. /**
  21933. * Serializes the current manager into a Serialization object
  21934. * @returns the serialized object
  21935. */
  21936. serialize(): any;
  21937. private _syncActiveTargets;
  21938. /**
  21939. * Syncrhonize the targets with all the meshes using this morph target manager
  21940. */
  21941. synchronize(): void;
  21942. /**
  21943. * Creates a new MorphTargetManager from serialized data
  21944. * @param serializationObject defines the serialized data
  21945. * @param scene defines the hosting scene
  21946. * @returns the new MorphTargetManager
  21947. */
  21948. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21949. }
  21950. }
  21951. declare module BABYLON {
  21952. /**
  21953. * Class used to represent a specific level of detail of a mesh
  21954. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21955. */
  21956. export class MeshLODLevel {
  21957. /** Defines the distance where this level should star being displayed */
  21958. distance: number;
  21959. /** Defines the mesh to use to render this level */
  21960. mesh: Nullable<Mesh>;
  21961. /**
  21962. * Creates a new LOD level
  21963. * @param distance defines the distance where this level should star being displayed
  21964. * @param mesh defines the mesh to use to render this level
  21965. */
  21966. constructor(
  21967. /** Defines the distance where this level should star being displayed */
  21968. distance: number,
  21969. /** Defines the mesh to use to render this level */
  21970. mesh: Nullable<Mesh>);
  21971. }
  21972. }
  21973. declare module BABYLON {
  21974. /**
  21975. * Mesh representing the gorund
  21976. */
  21977. export class GroundMesh extends Mesh {
  21978. /** If octree should be generated */
  21979. generateOctree: boolean;
  21980. private _heightQuads;
  21981. /** @hidden */
  21982. _subdivisionsX: number;
  21983. /** @hidden */
  21984. _subdivisionsY: number;
  21985. /** @hidden */
  21986. _width: number;
  21987. /** @hidden */
  21988. _height: number;
  21989. /** @hidden */
  21990. _minX: number;
  21991. /** @hidden */
  21992. _maxX: number;
  21993. /** @hidden */
  21994. _minZ: number;
  21995. /** @hidden */
  21996. _maxZ: number;
  21997. constructor(name: string, scene: Scene);
  21998. /**
  21999. * "GroundMesh"
  22000. * @returns "GroundMesh"
  22001. */
  22002. getClassName(): string;
  22003. /**
  22004. * The minimum of x and y subdivisions
  22005. */
  22006. readonly subdivisions: number;
  22007. /**
  22008. * X subdivisions
  22009. */
  22010. readonly subdivisionsX: number;
  22011. /**
  22012. * Y subdivisions
  22013. */
  22014. readonly subdivisionsY: number;
  22015. /**
  22016. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22017. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22018. * @param chunksCount the number of subdivisions for x and y
  22019. * @param octreeBlocksSize (Default: 32)
  22020. */
  22021. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22022. /**
  22023. * Returns a height (y) value in the Worl system :
  22024. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22025. * @param x x coordinate
  22026. * @param z z coordinate
  22027. * @returns the ground y position if (x, z) are outside the ground surface.
  22028. */
  22029. getHeightAtCoordinates(x: number, z: number): number;
  22030. /**
  22031. * Returns a normalized vector (Vector3) orthogonal to the ground
  22032. * at the ground coordinates (x, z) expressed in the World system.
  22033. * @param x x coordinate
  22034. * @param z z coordinate
  22035. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22036. */
  22037. getNormalAtCoordinates(x: number, z: number): Vector3;
  22038. /**
  22039. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22040. * at the ground coordinates (x, z) expressed in the World system.
  22041. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22042. * @param x x coordinate
  22043. * @param z z coordinate
  22044. * @param ref vector to store the result
  22045. * @returns the GroundMesh.
  22046. */
  22047. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22048. /**
  22049. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22050. * if the ground has been updated.
  22051. * This can be used in the render loop.
  22052. * @returns the GroundMesh.
  22053. */
  22054. updateCoordinateHeights(): GroundMesh;
  22055. private _getFacetAt;
  22056. private _initHeightQuads;
  22057. private _computeHeightQuads;
  22058. /**
  22059. * Serializes this ground mesh
  22060. * @param serializationObject object to write serialization to
  22061. */
  22062. serialize(serializationObject: any): void;
  22063. /**
  22064. * Parses a serialized ground mesh
  22065. * @param parsedMesh the serialized mesh
  22066. * @param scene the scene to create the ground mesh in
  22067. * @returns the created ground mesh
  22068. */
  22069. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22070. }
  22071. }
  22072. declare module BABYLON {
  22073. /**
  22074. * Interface for Physics-Joint data
  22075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22076. */
  22077. export interface PhysicsJointData {
  22078. /**
  22079. * The main pivot of the joint
  22080. */
  22081. mainPivot?: Vector3;
  22082. /**
  22083. * The connected pivot of the joint
  22084. */
  22085. connectedPivot?: Vector3;
  22086. /**
  22087. * The main axis of the joint
  22088. */
  22089. mainAxis?: Vector3;
  22090. /**
  22091. * The connected axis of the joint
  22092. */
  22093. connectedAxis?: Vector3;
  22094. /**
  22095. * The collision of the joint
  22096. */
  22097. collision?: boolean;
  22098. /**
  22099. * Native Oimo/Cannon/Energy data
  22100. */
  22101. nativeParams?: any;
  22102. }
  22103. /**
  22104. * This is a holder class for the physics joint created by the physics plugin
  22105. * It holds a set of functions to control the underlying joint
  22106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22107. */
  22108. export class PhysicsJoint {
  22109. /**
  22110. * The type of the physics joint
  22111. */
  22112. type: number;
  22113. /**
  22114. * The data for the physics joint
  22115. */
  22116. jointData: PhysicsJointData;
  22117. private _physicsJoint;
  22118. protected _physicsPlugin: IPhysicsEnginePlugin;
  22119. /**
  22120. * Initializes the physics joint
  22121. * @param type The type of the physics joint
  22122. * @param jointData The data for the physics joint
  22123. */
  22124. constructor(
  22125. /**
  22126. * The type of the physics joint
  22127. */
  22128. type: number,
  22129. /**
  22130. * The data for the physics joint
  22131. */
  22132. jointData: PhysicsJointData);
  22133. /**
  22134. * Gets the physics joint
  22135. */
  22136. /**
  22137. * Sets the physics joint
  22138. */
  22139. physicsJoint: any;
  22140. /**
  22141. * Sets the physics plugin
  22142. */
  22143. physicsPlugin: IPhysicsEnginePlugin;
  22144. /**
  22145. * Execute a function that is physics-plugin specific.
  22146. * @param {Function} func the function that will be executed.
  22147. * It accepts two parameters: the physics world and the physics joint
  22148. */
  22149. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22150. /**
  22151. * Distance-Joint type
  22152. */
  22153. static DistanceJoint: number;
  22154. /**
  22155. * Hinge-Joint type
  22156. */
  22157. static HingeJoint: number;
  22158. /**
  22159. * Ball-and-Socket joint type
  22160. */
  22161. static BallAndSocketJoint: number;
  22162. /**
  22163. * Wheel-Joint type
  22164. */
  22165. static WheelJoint: number;
  22166. /**
  22167. * Slider-Joint type
  22168. */
  22169. static SliderJoint: number;
  22170. /**
  22171. * Prismatic-Joint type
  22172. */
  22173. static PrismaticJoint: number;
  22174. /**
  22175. * Universal-Joint type
  22176. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22177. */
  22178. static UniversalJoint: number;
  22179. /**
  22180. * Hinge-Joint 2 type
  22181. */
  22182. static Hinge2Joint: number;
  22183. /**
  22184. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22185. */
  22186. static PointToPointJoint: number;
  22187. /**
  22188. * Spring-Joint type
  22189. */
  22190. static SpringJoint: number;
  22191. /**
  22192. * Lock-Joint type
  22193. */
  22194. static LockJoint: number;
  22195. }
  22196. /**
  22197. * A class representing a physics distance joint
  22198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22199. */
  22200. export class DistanceJoint extends PhysicsJoint {
  22201. /**
  22202. *
  22203. * @param jointData The data for the Distance-Joint
  22204. */
  22205. constructor(jointData: DistanceJointData);
  22206. /**
  22207. * Update the predefined distance.
  22208. * @param maxDistance The maximum preferred distance
  22209. * @param minDistance The minimum preferred distance
  22210. */
  22211. updateDistance(maxDistance: number, minDistance?: number): void;
  22212. }
  22213. /**
  22214. * Represents a Motor-Enabled Joint
  22215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22216. */
  22217. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22218. /**
  22219. * Initializes the Motor-Enabled Joint
  22220. * @param type The type of the joint
  22221. * @param jointData The physica joint data for the joint
  22222. */
  22223. constructor(type: number, jointData: PhysicsJointData);
  22224. /**
  22225. * Set the motor values.
  22226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22227. * @param force the force to apply
  22228. * @param maxForce max force for this motor.
  22229. */
  22230. setMotor(force?: number, maxForce?: number): void;
  22231. /**
  22232. * Set the motor's limits.
  22233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22234. * @param upperLimit The upper limit of the motor
  22235. * @param lowerLimit The lower limit of the motor
  22236. */
  22237. setLimit(upperLimit: number, lowerLimit?: number): void;
  22238. }
  22239. /**
  22240. * This class represents a single physics Hinge-Joint
  22241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22242. */
  22243. export class HingeJoint extends MotorEnabledJoint {
  22244. /**
  22245. * Initializes the Hinge-Joint
  22246. * @param jointData The joint data for the Hinge-Joint
  22247. */
  22248. constructor(jointData: PhysicsJointData);
  22249. /**
  22250. * Set the motor values.
  22251. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22252. * @param {number} force the force to apply
  22253. * @param {number} maxForce max force for this motor.
  22254. */
  22255. setMotor(force?: number, maxForce?: number): void;
  22256. /**
  22257. * Set the motor's limits.
  22258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22259. * @param upperLimit The upper limit of the motor
  22260. * @param lowerLimit The lower limit of the motor
  22261. */
  22262. setLimit(upperLimit: number, lowerLimit?: number): void;
  22263. }
  22264. /**
  22265. * This class represents a dual hinge physics joint (same as wheel joint)
  22266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22267. */
  22268. export class Hinge2Joint extends MotorEnabledJoint {
  22269. /**
  22270. * Initializes the Hinge2-Joint
  22271. * @param jointData The joint data for the Hinge2-Joint
  22272. */
  22273. constructor(jointData: PhysicsJointData);
  22274. /**
  22275. * Set the motor values.
  22276. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22277. * @param {number} targetSpeed the speed the motor is to reach
  22278. * @param {number} maxForce max force for this motor.
  22279. * @param {motorIndex} the motor's index, 0 or 1.
  22280. */
  22281. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22282. /**
  22283. * Set the motor limits.
  22284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22285. * @param {number} upperLimit the upper limit
  22286. * @param {number} lowerLimit lower limit
  22287. * @param {motorIndex} the motor's index, 0 or 1.
  22288. */
  22289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22290. }
  22291. /**
  22292. * Interface for a motor enabled joint
  22293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22294. */
  22295. export interface IMotorEnabledJoint {
  22296. /**
  22297. * Physics joint
  22298. */
  22299. physicsJoint: any;
  22300. /**
  22301. * Sets the motor of the motor-enabled joint
  22302. * @param force The force of the motor
  22303. * @param maxForce The maximum force of the motor
  22304. * @param motorIndex The index of the motor
  22305. */
  22306. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22307. /**
  22308. * Sets the limit of the motor
  22309. * @param upperLimit The upper limit of the motor
  22310. * @param lowerLimit The lower limit of the motor
  22311. * @param motorIndex The index of the motor
  22312. */
  22313. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22314. }
  22315. /**
  22316. * Joint data for a Distance-Joint
  22317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22318. */
  22319. export interface DistanceJointData extends PhysicsJointData {
  22320. /**
  22321. * Max distance the 2 joint objects can be apart
  22322. */
  22323. maxDistance: number;
  22324. }
  22325. /**
  22326. * Joint data from a spring joint
  22327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22328. */
  22329. export interface SpringJointData extends PhysicsJointData {
  22330. /**
  22331. * Length of the spring
  22332. */
  22333. length: number;
  22334. /**
  22335. * Stiffness of the spring
  22336. */
  22337. stiffness: number;
  22338. /**
  22339. * Damping of the spring
  22340. */
  22341. damping: number;
  22342. /** this callback will be called when applying the force to the impostors. */
  22343. forceApplicationCallback: () => void;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Holds the data for the raycast result
  22349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22350. */
  22351. export class PhysicsRaycastResult {
  22352. private _hasHit;
  22353. private _hitDistance;
  22354. private _hitNormalWorld;
  22355. private _hitPointWorld;
  22356. private _rayFromWorld;
  22357. private _rayToWorld;
  22358. /**
  22359. * Gets if there was a hit
  22360. */
  22361. readonly hasHit: boolean;
  22362. /**
  22363. * Gets the distance from the hit
  22364. */
  22365. readonly hitDistance: number;
  22366. /**
  22367. * Gets the hit normal/direction in the world
  22368. */
  22369. readonly hitNormalWorld: Vector3;
  22370. /**
  22371. * Gets the hit point in the world
  22372. */
  22373. readonly hitPointWorld: Vector3;
  22374. /**
  22375. * Gets the ray "start point" of the ray in the world
  22376. */
  22377. readonly rayFromWorld: Vector3;
  22378. /**
  22379. * Gets the ray "end point" of the ray in the world
  22380. */
  22381. readonly rayToWorld: Vector3;
  22382. /**
  22383. * Sets the hit data (normal & point in world space)
  22384. * @param hitNormalWorld defines the normal in world space
  22385. * @param hitPointWorld defines the point in world space
  22386. */
  22387. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22388. /**
  22389. * Sets the distance from the start point to the hit point
  22390. * @param distance
  22391. */
  22392. setHitDistance(distance: number): void;
  22393. /**
  22394. * Calculates the distance manually
  22395. */
  22396. calculateHitDistance(): void;
  22397. /**
  22398. * Resets all the values to default
  22399. * @param from The from point on world space
  22400. * @param to The to point on world space
  22401. */
  22402. reset(from?: Vector3, to?: Vector3): void;
  22403. }
  22404. /**
  22405. * Interface for the size containing width and height
  22406. */
  22407. interface IXYZ {
  22408. /**
  22409. * X
  22410. */
  22411. x: number;
  22412. /**
  22413. * Y
  22414. */
  22415. y: number;
  22416. /**
  22417. * Z
  22418. */
  22419. z: number;
  22420. }
  22421. }
  22422. declare module BABYLON {
  22423. /**
  22424. * Interface used to describe a physics joint
  22425. */
  22426. export interface PhysicsImpostorJoint {
  22427. /** Defines the main impostor to which the joint is linked */
  22428. mainImpostor: PhysicsImpostor;
  22429. /** Defines the impostor that is connected to the main impostor using this joint */
  22430. connectedImpostor: PhysicsImpostor;
  22431. /** Defines the joint itself */
  22432. joint: PhysicsJoint;
  22433. }
  22434. /** @hidden */
  22435. export interface IPhysicsEnginePlugin {
  22436. world: any;
  22437. name: string;
  22438. setGravity(gravity: Vector3): void;
  22439. setTimeStep(timeStep: number): void;
  22440. getTimeStep(): number;
  22441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22445. removePhysicsBody(impostor: PhysicsImpostor): void;
  22446. generateJoint(joint: PhysicsImpostorJoint): void;
  22447. removeJoint(joint: PhysicsImpostorJoint): void;
  22448. isSupported(): boolean;
  22449. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22450. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22451. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22452. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22453. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22454. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22455. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22456. getBodyMass(impostor: PhysicsImpostor): number;
  22457. getBodyFriction(impostor: PhysicsImpostor): number;
  22458. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22459. getBodyRestitution(impostor: PhysicsImpostor): number;
  22460. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22461. getBodyPressure?(impostor: PhysicsImpostor): number;
  22462. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22463. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22464. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22465. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22466. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22467. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22468. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22469. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22470. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22471. sleepBody(impostor: PhysicsImpostor): void;
  22472. wakeUpBody(impostor: PhysicsImpostor): void;
  22473. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22475. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22476. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22477. getRadius(impostor: PhysicsImpostor): number;
  22478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22479. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22480. dispose(): void;
  22481. }
  22482. /**
  22483. * Interface used to define a physics engine
  22484. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22485. */
  22486. export interface IPhysicsEngine {
  22487. /**
  22488. * Gets the gravity vector used by the simulation
  22489. */
  22490. gravity: Vector3;
  22491. /**
  22492. * Sets the gravity vector used by the simulation
  22493. * @param gravity defines the gravity vector to use
  22494. */
  22495. setGravity(gravity: Vector3): void;
  22496. /**
  22497. * Set the time step of the physics engine.
  22498. * Default is 1/60.
  22499. * To slow it down, enter 1/600 for example.
  22500. * To speed it up, 1/30
  22501. * @param newTimeStep the new timestep to apply to this world.
  22502. */
  22503. setTimeStep(newTimeStep: number): void;
  22504. /**
  22505. * Get the time step of the physics engine.
  22506. * @returns the current time step
  22507. */
  22508. getTimeStep(): number;
  22509. /**
  22510. * Release all resources
  22511. */
  22512. dispose(): void;
  22513. /**
  22514. * Gets the name of the current physics plugin
  22515. * @returns the name of the plugin
  22516. */
  22517. getPhysicsPluginName(): string;
  22518. /**
  22519. * Adding a new impostor for the impostor tracking.
  22520. * This will be done by the impostor itself.
  22521. * @param impostor the impostor to add
  22522. */
  22523. addImpostor(impostor: PhysicsImpostor): void;
  22524. /**
  22525. * Remove an impostor from the engine.
  22526. * This impostor and its mesh will not longer be updated by the physics engine.
  22527. * @param impostor the impostor to remove
  22528. */
  22529. removeImpostor(impostor: PhysicsImpostor): void;
  22530. /**
  22531. * Add a joint to the physics engine
  22532. * @param mainImpostor defines the main impostor to which the joint is added.
  22533. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22534. * @param joint defines the joint that will connect both impostors.
  22535. */
  22536. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22537. /**
  22538. * Removes a joint from the simulation
  22539. * @param mainImpostor defines the impostor used with the joint
  22540. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22541. * @param joint defines the joint to remove
  22542. */
  22543. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22544. /**
  22545. * Gets the current plugin used to run the simulation
  22546. * @returns current plugin
  22547. */
  22548. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22549. /**
  22550. * Gets the list of physic impostors
  22551. * @returns an array of PhysicsImpostor
  22552. */
  22553. getImpostors(): Array<PhysicsImpostor>;
  22554. /**
  22555. * Gets the impostor for a physics enabled object
  22556. * @param object defines the object impersonated by the impostor
  22557. * @returns the PhysicsImpostor or null if not found
  22558. */
  22559. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22560. /**
  22561. * Gets the impostor for a physics body object
  22562. * @param body defines physics body used by the impostor
  22563. * @returns the PhysicsImpostor or null if not found
  22564. */
  22565. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22566. /**
  22567. * Does a raycast in the physics world
  22568. * @param from when should the ray start?
  22569. * @param to when should the ray end?
  22570. * @returns PhysicsRaycastResult
  22571. */
  22572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22573. /**
  22574. * Called by the scene. No need to call it.
  22575. * @param delta defines the timespam between frames
  22576. */
  22577. _step(delta: number): void;
  22578. }
  22579. }
  22580. declare module BABYLON {
  22581. /**
  22582. * The interface for the physics imposter parameters
  22583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22584. */
  22585. export interface PhysicsImpostorParameters {
  22586. /**
  22587. * The mass of the physics imposter
  22588. */
  22589. mass: number;
  22590. /**
  22591. * The friction of the physics imposter
  22592. */
  22593. friction?: number;
  22594. /**
  22595. * The coefficient of restitution of the physics imposter
  22596. */
  22597. restitution?: number;
  22598. /**
  22599. * The native options of the physics imposter
  22600. */
  22601. nativeOptions?: any;
  22602. /**
  22603. * Specifies if the parent should be ignored
  22604. */
  22605. ignoreParent?: boolean;
  22606. /**
  22607. * Specifies if bi-directional transformations should be disabled
  22608. */
  22609. disableBidirectionalTransformation?: boolean;
  22610. /**
  22611. * The pressure inside the physics imposter, soft object only
  22612. */
  22613. pressure?: number;
  22614. /**
  22615. * The stiffness the physics imposter, soft object only
  22616. */
  22617. stiffness?: number;
  22618. /**
  22619. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22620. */
  22621. velocityIterations?: number;
  22622. /**
  22623. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22624. */
  22625. positionIterations?: number;
  22626. /**
  22627. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22628. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22629. * Add to fix multiple points
  22630. */
  22631. fixedPoints?: number;
  22632. /**
  22633. * The collision margin around a soft object
  22634. */
  22635. margin?: number;
  22636. /**
  22637. * The collision margin around a soft object
  22638. */
  22639. damping?: number;
  22640. /**
  22641. * The path for a rope based on an extrusion
  22642. */
  22643. path?: any;
  22644. /**
  22645. * The shape of an extrusion used for a rope based on an extrusion
  22646. */
  22647. shape?: any;
  22648. }
  22649. /**
  22650. * Interface for a physics-enabled object
  22651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22652. */
  22653. export interface IPhysicsEnabledObject {
  22654. /**
  22655. * The position of the physics-enabled object
  22656. */
  22657. position: Vector3;
  22658. /**
  22659. * The rotation of the physics-enabled object
  22660. */
  22661. rotationQuaternion: Nullable<Quaternion>;
  22662. /**
  22663. * The scale of the physics-enabled object
  22664. */
  22665. scaling: Vector3;
  22666. /**
  22667. * The rotation of the physics-enabled object
  22668. */
  22669. rotation?: Vector3;
  22670. /**
  22671. * The parent of the physics-enabled object
  22672. */
  22673. parent?: any;
  22674. /**
  22675. * The bounding info of the physics-enabled object
  22676. * @returns The bounding info of the physics-enabled object
  22677. */
  22678. getBoundingInfo(): BoundingInfo;
  22679. /**
  22680. * Computes the world matrix
  22681. * @param force Specifies if the world matrix should be computed by force
  22682. * @returns A world matrix
  22683. */
  22684. computeWorldMatrix(force: boolean): Matrix;
  22685. /**
  22686. * Gets the world matrix
  22687. * @returns A world matrix
  22688. */
  22689. getWorldMatrix?(): Matrix;
  22690. /**
  22691. * Gets the child meshes
  22692. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22693. * @returns An array of abstract meshes
  22694. */
  22695. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22696. /**
  22697. * Gets the vertex data
  22698. * @param kind The type of vertex data
  22699. * @returns A nullable array of numbers, or a float32 array
  22700. */
  22701. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22702. /**
  22703. * Gets the indices from the mesh
  22704. * @returns A nullable array of index arrays
  22705. */
  22706. getIndices?(): Nullable<IndicesArray>;
  22707. /**
  22708. * Gets the scene from the mesh
  22709. * @returns the indices array or null
  22710. */
  22711. getScene?(): Scene;
  22712. /**
  22713. * Gets the absolute position from the mesh
  22714. * @returns the absolute position
  22715. */
  22716. getAbsolutePosition(): Vector3;
  22717. /**
  22718. * Gets the absolute pivot point from the mesh
  22719. * @returns the absolute pivot point
  22720. */
  22721. getAbsolutePivotPoint(): Vector3;
  22722. /**
  22723. * Rotates the mesh
  22724. * @param axis The axis of rotation
  22725. * @param amount The amount of rotation
  22726. * @param space The space of the rotation
  22727. * @returns The rotation transform node
  22728. */
  22729. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22730. /**
  22731. * Translates the mesh
  22732. * @param axis The axis of translation
  22733. * @param distance The distance of translation
  22734. * @param space The space of the translation
  22735. * @returns The transform node
  22736. */
  22737. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22738. /**
  22739. * Sets the absolute position of the mesh
  22740. * @param absolutePosition The absolute position of the mesh
  22741. * @returns The transform node
  22742. */
  22743. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22744. /**
  22745. * Gets the class name of the mesh
  22746. * @returns The class name
  22747. */
  22748. getClassName(): string;
  22749. }
  22750. /**
  22751. * Represents a physics imposter
  22752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22753. */
  22754. export class PhysicsImpostor {
  22755. /**
  22756. * The physics-enabled object used as the physics imposter
  22757. */
  22758. object: IPhysicsEnabledObject;
  22759. /**
  22760. * The type of the physics imposter
  22761. */
  22762. type: number;
  22763. private _options;
  22764. private _scene?;
  22765. /**
  22766. * The default object size of the imposter
  22767. */
  22768. static DEFAULT_OBJECT_SIZE: Vector3;
  22769. /**
  22770. * The identity quaternion of the imposter
  22771. */
  22772. static IDENTITY_QUATERNION: Quaternion;
  22773. /** @hidden */
  22774. _pluginData: any;
  22775. private _physicsEngine;
  22776. private _physicsBody;
  22777. private _bodyUpdateRequired;
  22778. private _onBeforePhysicsStepCallbacks;
  22779. private _onAfterPhysicsStepCallbacks;
  22780. /** @hidden */
  22781. _onPhysicsCollideCallbacks: Array<{
  22782. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22783. otherImpostors: Array<PhysicsImpostor>;
  22784. }>;
  22785. private _deltaPosition;
  22786. private _deltaRotation;
  22787. private _deltaRotationConjugated;
  22788. /** @hidden */
  22789. _isFromLine: boolean;
  22790. private _parent;
  22791. private _isDisposed;
  22792. private static _tmpVecs;
  22793. private static _tmpQuat;
  22794. /**
  22795. * Specifies if the physics imposter is disposed
  22796. */
  22797. readonly isDisposed: boolean;
  22798. /**
  22799. * Gets the mass of the physics imposter
  22800. */
  22801. mass: number;
  22802. /**
  22803. * Gets the coefficient of friction
  22804. */
  22805. /**
  22806. * Sets the coefficient of friction
  22807. */
  22808. friction: number;
  22809. /**
  22810. * Gets the coefficient of restitution
  22811. */
  22812. /**
  22813. * Sets the coefficient of restitution
  22814. */
  22815. restitution: number;
  22816. /**
  22817. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22818. */
  22819. /**
  22820. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22821. */
  22822. pressure: number;
  22823. /**
  22824. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22825. */
  22826. /**
  22827. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22828. */
  22829. stiffness: number;
  22830. /**
  22831. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22832. */
  22833. /**
  22834. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22835. */
  22836. velocityIterations: number;
  22837. /**
  22838. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22839. */
  22840. /**
  22841. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22842. */
  22843. positionIterations: number;
  22844. /**
  22845. * The unique id of the physics imposter
  22846. * set by the physics engine when adding this impostor to the array
  22847. */
  22848. uniqueId: number;
  22849. /**
  22850. * @hidden
  22851. */
  22852. soft: boolean;
  22853. /**
  22854. * @hidden
  22855. */
  22856. segments: number;
  22857. private _joints;
  22858. /**
  22859. * Initializes the physics imposter
  22860. * @param object The physics-enabled object used as the physics imposter
  22861. * @param type The type of the physics imposter
  22862. * @param _options The options for the physics imposter
  22863. * @param _scene The Babylon scene
  22864. */
  22865. constructor(
  22866. /**
  22867. * The physics-enabled object used as the physics imposter
  22868. */
  22869. object: IPhysicsEnabledObject,
  22870. /**
  22871. * The type of the physics imposter
  22872. */
  22873. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22874. /**
  22875. * This function will completly initialize this impostor.
  22876. * It will create a new body - but only if this mesh has no parent.
  22877. * If it has, this impostor will not be used other than to define the impostor
  22878. * of the child mesh.
  22879. * @hidden
  22880. */
  22881. _init(): void;
  22882. private _getPhysicsParent;
  22883. /**
  22884. * Should a new body be generated.
  22885. * @returns boolean specifying if body initialization is required
  22886. */
  22887. isBodyInitRequired(): boolean;
  22888. /**
  22889. * Sets the updated scaling
  22890. * @param updated Specifies if the scaling is updated
  22891. */
  22892. setScalingUpdated(): void;
  22893. /**
  22894. * Force a regeneration of this or the parent's impostor's body.
  22895. * Use under cautious - This will remove all joints already implemented.
  22896. */
  22897. forceUpdate(): void;
  22898. /**
  22899. * Gets the body that holds this impostor. Either its own, or its parent.
  22900. */
  22901. /**
  22902. * Set the physics body. Used mainly by the physics engine/plugin
  22903. */
  22904. physicsBody: any;
  22905. /**
  22906. * Get the parent of the physics imposter
  22907. * @returns Physics imposter or null
  22908. */
  22909. /**
  22910. * Sets the parent of the physics imposter
  22911. */
  22912. parent: Nullable<PhysicsImpostor>;
  22913. /**
  22914. * Resets the update flags
  22915. */
  22916. resetUpdateFlags(): void;
  22917. /**
  22918. * Gets the object extend size
  22919. * @returns the object extend size
  22920. */
  22921. getObjectExtendSize(): Vector3;
  22922. /**
  22923. * Gets the object center
  22924. * @returns The object center
  22925. */
  22926. getObjectCenter(): Vector3;
  22927. /**
  22928. * Get a specific parametes from the options parameter
  22929. * @param paramName The object parameter name
  22930. * @returns The object parameter
  22931. */
  22932. getParam(paramName: string): any;
  22933. /**
  22934. * Sets a specific parameter in the options given to the physics plugin
  22935. * @param paramName The parameter name
  22936. * @param value The value of the parameter
  22937. */
  22938. setParam(paramName: string, value: number): void;
  22939. /**
  22940. * Specifically change the body's mass option. Won't recreate the physics body object
  22941. * @param mass The mass of the physics imposter
  22942. */
  22943. setMass(mass: number): void;
  22944. /**
  22945. * Gets the linear velocity
  22946. * @returns linear velocity or null
  22947. */
  22948. getLinearVelocity(): Nullable<Vector3>;
  22949. /**
  22950. * Sets the linear velocity
  22951. * @param velocity linear velocity or null
  22952. */
  22953. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22954. /**
  22955. * Gets the angular velocity
  22956. * @returns angular velocity or null
  22957. */
  22958. getAngularVelocity(): Nullable<Vector3>;
  22959. /**
  22960. * Sets the angular velocity
  22961. * @param velocity The velocity or null
  22962. */
  22963. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22964. /**
  22965. * Execute a function with the physics plugin native code
  22966. * Provide a function the will have two variables - the world object and the physics body object
  22967. * @param func The function to execute with the physics plugin native code
  22968. */
  22969. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22970. /**
  22971. * Register a function that will be executed before the physics world is stepping forward
  22972. * @param func The function to execute before the physics world is stepped forward
  22973. */
  22974. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22975. /**
  22976. * Unregister a function that will be executed before the physics world is stepping forward
  22977. * @param func The function to execute before the physics world is stepped forward
  22978. */
  22979. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22980. /**
  22981. * Register a function that will be executed after the physics step
  22982. * @param func The function to execute after physics step
  22983. */
  22984. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22985. /**
  22986. * Unregisters a function that will be executed after the physics step
  22987. * @param func The function to execute after physics step
  22988. */
  22989. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22990. /**
  22991. * register a function that will be executed when this impostor collides against a different body
  22992. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22993. * @param func Callback that is executed on collision
  22994. */
  22995. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22996. /**
  22997. * Unregisters the physics imposter on contact
  22998. * @param collideAgainst The physics object to collide against
  22999. * @param func Callback to execute on collision
  23000. */
  23001. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23002. private _tmpQuat;
  23003. private _tmpQuat2;
  23004. /**
  23005. * Get the parent rotation
  23006. * @returns The parent rotation
  23007. */
  23008. getParentsRotation(): Quaternion;
  23009. /**
  23010. * this function is executed by the physics engine.
  23011. */
  23012. beforeStep: () => void;
  23013. /**
  23014. * this function is executed by the physics engine
  23015. */
  23016. afterStep: () => void;
  23017. /**
  23018. * Legacy collision detection event support
  23019. */
  23020. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23021. /**
  23022. * event and body object due to cannon's event-based architecture.
  23023. */
  23024. onCollide: (e: {
  23025. body: any;
  23026. }) => void;
  23027. /**
  23028. * Apply a force
  23029. * @param force The force to apply
  23030. * @param contactPoint The contact point for the force
  23031. * @returns The physics imposter
  23032. */
  23033. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23034. /**
  23035. * Apply an impulse
  23036. * @param force The impulse force
  23037. * @param contactPoint The contact point for the impulse force
  23038. * @returns The physics imposter
  23039. */
  23040. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23041. /**
  23042. * A help function to create a joint
  23043. * @param otherImpostor A physics imposter used to create a joint
  23044. * @param jointType The type of joint
  23045. * @param jointData The data for the joint
  23046. * @returns The physics imposter
  23047. */
  23048. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23049. /**
  23050. * Add a joint to this impostor with a different impostor
  23051. * @param otherImpostor A physics imposter used to add a joint
  23052. * @param joint The joint to add
  23053. * @returns The physics imposter
  23054. */
  23055. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23056. /**
  23057. * Add an anchor to a cloth impostor
  23058. * @param otherImpostor rigid impostor to anchor to
  23059. * @param width ratio across width from 0 to 1
  23060. * @param height ratio up height from 0 to 1
  23061. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23062. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23063. * @returns impostor the soft imposter
  23064. */
  23065. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23066. /**
  23067. * Add a hook to a rope impostor
  23068. * @param otherImpostor rigid impostor to anchor to
  23069. * @param length ratio across rope from 0 to 1
  23070. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23071. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23072. * @returns impostor the rope imposter
  23073. */
  23074. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23075. /**
  23076. * Will keep this body still, in a sleep mode.
  23077. * @returns the physics imposter
  23078. */
  23079. sleep(): PhysicsImpostor;
  23080. /**
  23081. * Wake the body up.
  23082. * @returns The physics imposter
  23083. */
  23084. wakeUp(): PhysicsImpostor;
  23085. /**
  23086. * Clones the physics imposter
  23087. * @param newObject The physics imposter clones to this physics-enabled object
  23088. * @returns A nullable physics imposter
  23089. */
  23090. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23091. /**
  23092. * Disposes the physics imposter
  23093. */
  23094. dispose(): void;
  23095. /**
  23096. * Sets the delta position
  23097. * @param position The delta position amount
  23098. */
  23099. setDeltaPosition(position: Vector3): void;
  23100. /**
  23101. * Sets the delta rotation
  23102. * @param rotation The delta rotation amount
  23103. */
  23104. setDeltaRotation(rotation: Quaternion): void;
  23105. /**
  23106. * Gets the box size of the physics imposter and stores the result in the input parameter
  23107. * @param result Stores the box size
  23108. * @returns The physics imposter
  23109. */
  23110. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23111. /**
  23112. * Gets the radius of the physics imposter
  23113. * @returns Radius of the physics imposter
  23114. */
  23115. getRadius(): number;
  23116. /**
  23117. * Sync a bone with this impostor
  23118. * @param bone The bone to sync to the impostor.
  23119. * @param boneMesh The mesh that the bone is influencing.
  23120. * @param jointPivot The pivot of the joint / bone in local space.
  23121. * @param distToJoint Optional distance from the impostor to the joint.
  23122. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23123. */
  23124. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23125. /**
  23126. * Sync impostor to a bone
  23127. * @param bone The bone that the impostor will be synced to.
  23128. * @param boneMesh The mesh that the bone is influencing.
  23129. * @param jointPivot The pivot of the joint / bone in local space.
  23130. * @param distToJoint Optional distance from the impostor to the joint.
  23131. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23132. * @param boneAxis Optional vector3 axis the bone is aligned with
  23133. */
  23134. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23135. /**
  23136. * No-Imposter type
  23137. */
  23138. static NoImpostor: number;
  23139. /**
  23140. * Sphere-Imposter type
  23141. */
  23142. static SphereImpostor: number;
  23143. /**
  23144. * Box-Imposter type
  23145. */
  23146. static BoxImpostor: number;
  23147. /**
  23148. * Plane-Imposter type
  23149. */
  23150. static PlaneImpostor: number;
  23151. /**
  23152. * Mesh-imposter type
  23153. */
  23154. static MeshImpostor: number;
  23155. /**
  23156. * Capsule-Impostor type (Ammo.js plugin only)
  23157. */
  23158. static CapsuleImpostor: number;
  23159. /**
  23160. * Cylinder-Imposter type
  23161. */
  23162. static CylinderImpostor: number;
  23163. /**
  23164. * Particle-Imposter type
  23165. */
  23166. static ParticleImpostor: number;
  23167. /**
  23168. * Heightmap-Imposter type
  23169. */
  23170. static HeightmapImpostor: number;
  23171. /**
  23172. * ConvexHull-Impostor type (Ammo.js plugin only)
  23173. */
  23174. static ConvexHullImpostor: number;
  23175. /**
  23176. * Rope-Imposter type
  23177. */
  23178. static RopeImpostor: number;
  23179. /**
  23180. * Cloth-Imposter type
  23181. */
  23182. static ClothImpostor: number;
  23183. /**
  23184. * Softbody-Imposter type
  23185. */
  23186. static SoftbodyImpostor: number;
  23187. }
  23188. }
  23189. declare module BABYLON {
  23190. /**
  23191. * @hidden
  23192. **/
  23193. export class _CreationDataStorage {
  23194. closePath?: boolean;
  23195. closeArray?: boolean;
  23196. idx: number[];
  23197. dashSize: number;
  23198. gapSize: number;
  23199. path3D: Path3D;
  23200. pathArray: Vector3[][];
  23201. arc: number;
  23202. radius: number;
  23203. cap: number;
  23204. tessellation: number;
  23205. }
  23206. /**
  23207. * @hidden
  23208. **/
  23209. class _InstanceDataStorage {
  23210. visibleInstances: any;
  23211. batchCache: _InstancesBatch;
  23212. instancesBufferSize: number;
  23213. instancesBuffer: Nullable<Buffer>;
  23214. instancesData: Float32Array;
  23215. overridenInstanceCount: number;
  23216. isFrozen: boolean;
  23217. previousBatch: Nullable<_InstancesBatch>;
  23218. hardwareInstancedRendering: boolean;
  23219. sideOrientation: number;
  23220. }
  23221. /**
  23222. * @hidden
  23223. **/
  23224. export class _InstancesBatch {
  23225. mustReturn: boolean;
  23226. visibleInstances: Nullable<InstancedMesh[]>[];
  23227. renderSelf: boolean[];
  23228. hardwareInstancedRendering: boolean[];
  23229. }
  23230. /**
  23231. * Class used to represent renderable models
  23232. */
  23233. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23234. /**
  23235. * Mesh side orientation : usually the external or front surface
  23236. */
  23237. static readonly FRONTSIDE: number;
  23238. /**
  23239. * Mesh side orientation : usually the internal or back surface
  23240. */
  23241. static readonly BACKSIDE: number;
  23242. /**
  23243. * Mesh side orientation : both internal and external or front and back surfaces
  23244. */
  23245. static readonly DOUBLESIDE: number;
  23246. /**
  23247. * Mesh side orientation : by default, `FRONTSIDE`
  23248. */
  23249. static readonly DEFAULTSIDE: number;
  23250. /**
  23251. * Mesh cap setting : no cap
  23252. */
  23253. static readonly NO_CAP: number;
  23254. /**
  23255. * Mesh cap setting : one cap at the beginning of the mesh
  23256. */
  23257. static readonly CAP_START: number;
  23258. /**
  23259. * Mesh cap setting : one cap at the end of the mesh
  23260. */
  23261. static readonly CAP_END: number;
  23262. /**
  23263. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23264. */
  23265. static readonly CAP_ALL: number;
  23266. /**
  23267. * Mesh pattern setting : no flip or rotate
  23268. */
  23269. static readonly NO_FLIP: number;
  23270. /**
  23271. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23272. */
  23273. static readonly FLIP_TILE: number;
  23274. /**
  23275. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23276. */
  23277. static readonly ROTATE_TILE: number;
  23278. /**
  23279. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23280. */
  23281. static readonly FLIP_ROW: number;
  23282. /**
  23283. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23284. */
  23285. static readonly ROTATE_ROW: number;
  23286. /**
  23287. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23288. */
  23289. static readonly FLIP_N_ROTATE_TILE: number;
  23290. /**
  23291. * Mesh pattern setting : rotate pattern and rotate
  23292. */
  23293. static readonly FLIP_N_ROTATE_ROW: number;
  23294. /**
  23295. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23296. */
  23297. static readonly CENTER: number;
  23298. /**
  23299. * Mesh tile positioning : part tiles on left
  23300. */
  23301. static readonly LEFT: number;
  23302. /**
  23303. * Mesh tile positioning : part tiles on right
  23304. */
  23305. static readonly RIGHT: number;
  23306. /**
  23307. * Mesh tile positioning : part tiles on top
  23308. */
  23309. static readonly TOP: number;
  23310. /**
  23311. * Mesh tile positioning : part tiles on bottom
  23312. */
  23313. static readonly BOTTOM: number;
  23314. /**
  23315. * Gets the default side orientation.
  23316. * @param orientation the orientation to value to attempt to get
  23317. * @returns the default orientation
  23318. * @hidden
  23319. */
  23320. static _GetDefaultSideOrientation(orientation?: number): number;
  23321. private _internalMeshDataInfo;
  23322. /**
  23323. * An event triggered before rendering the mesh
  23324. */
  23325. readonly onBeforeRenderObservable: Observable<Mesh>;
  23326. /**
  23327. * An event triggered before binding the mesh
  23328. */
  23329. readonly onBeforeBindObservable: Observable<Mesh>;
  23330. /**
  23331. * An event triggered after rendering the mesh
  23332. */
  23333. readonly onAfterRenderObservable: Observable<Mesh>;
  23334. /**
  23335. * An event triggered before drawing the mesh
  23336. */
  23337. readonly onBeforeDrawObservable: Observable<Mesh>;
  23338. private _onBeforeDrawObserver;
  23339. /**
  23340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23341. */
  23342. onBeforeDraw: () => void;
  23343. /**
  23344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23345. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23346. */
  23347. delayLoadState: number;
  23348. /**
  23349. * Gets the list of instances created from this mesh
  23350. * it is not supposed to be modified manually.
  23351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23353. */
  23354. instances: InstancedMesh[];
  23355. /**
  23356. * Gets the file containing delay loading data for this mesh
  23357. */
  23358. delayLoadingFile: string;
  23359. /** @hidden */
  23360. _binaryInfo: any;
  23361. /**
  23362. * User defined function used to change how LOD level selection is done
  23363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23364. */
  23365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23366. /**
  23367. * Gets or sets the morph target manager
  23368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23369. */
  23370. morphTargetManager: Nullable<MorphTargetManager>;
  23371. /** @hidden */
  23372. _creationDataStorage: Nullable<_CreationDataStorage>;
  23373. /** @hidden */
  23374. _geometry: Nullable<Geometry>;
  23375. /** @hidden */
  23376. _delayInfo: Array<string>;
  23377. /** @hidden */
  23378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23379. /** @hidden */
  23380. _instanceDataStorage: _InstanceDataStorage;
  23381. private _effectiveMaterial;
  23382. /** @hidden */
  23383. _shouldGenerateFlatShading: boolean;
  23384. /** @hidden */
  23385. _originalBuilderSideOrientation: number;
  23386. /**
  23387. * Use this property to change the original side orientation defined at construction time
  23388. */
  23389. overrideMaterialSideOrientation: Nullable<number>;
  23390. /**
  23391. * Gets the source mesh (the one used to clone this one from)
  23392. */
  23393. readonly source: Nullable<Mesh>;
  23394. /**
  23395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23396. */
  23397. isUnIndexed: boolean;
  23398. /**
  23399. * @constructor
  23400. * @param name The value used by scene.getMeshByName() to do a lookup.
  23401. * @param scene The scene to add this mesh to.
  23402. * @param parent The parent of this mesh, if it has one
  23403. * @param source An optional Mesh from which geometry is shared, cloned.
  23404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23405. * When false, achieved by calling a clone(), also passing False.
  23406. * This will make creation of children, recursive.
  23407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23408. */
  23409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23410. /**
  23411. * Gets the class name
  23412. * @returns the string "Mesh".
  23413. */
  23414. getClassName(): string;
  23415. /** @hidden */
  23416. readonly _isMesh: boolean;
  23417. /**
  23418. * Returns a description of this mesh
  23419. * @param fullDetails define if full details about this mesh must be used
  23420. * @returns a descriptive string representing this mesh
  23421. */
  23422. toString(fullDetails?: boolean): string;
  23423. /** @hidden */
  23424. _unBindEffect(): void;
  23425. /**
  23426. * Gets a boolean indicating if this mesh has LOD
  23427. */
  23428. readonly hasLODLevels: boolean;
  23429. /**
  23430. * Gets the list of MeshLODLevel associated with the current mesh
  23431. * @returns an array of MeshLODLevel
  23432. */
  23433. getLODLevels(): MeshLODLevel[];
  23434. private _sortLODLevels;
  23435. /**
  23436. * Add a mesh as LOD level triggered at the given distance.
  23437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23438. * @param distance The distance from the center of the object to show this level
  23439. * @param mesh The mesh to be added as LOD level (can be null)
  23440. * @return This mesh (for chaining)
  23441. */
  23442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23443. /**
  23444. * Returns the LOD level mesh at the passed distance or null if not found.
  23445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23446. * @param distance The distance from the center of the object to show this level
  23447. * @returns a Mesh or `null`
  23448. */
  23449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23450. /**
  23451. * Remove a mesh from the LOD array
  23452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23453. * @param mesh defines the mesh to be removed
  23454. * @return This mesh (for chaining)
  23455. */
  23456. removeLODLevel(mesh: Mesh): Mesh;
  23457. /**
  23458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23460. * @param camera defines the camera to use to compute distance
  23461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23462. * @return This mesh (for chaining)
  23463. */
  23464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23465. /**
  23466. * Gets the mesh internal Geometry object
  23467. */
  23468. readonly geometry: Nullable<Geometry>;
  23469. /**
  23470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23471. * @returns the total number of vertices
  23472. */
  23473. getTotalVertices(): number;
  23474. /**
  23475. * Returns the content of an associated vertex buffer
  23476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23477. * - VertexBuffer.PositionKind
  23478. * - VertexBuffer.UVKind
  23479. * - VertexBuffer.UV2Kind
  23480. * - VertexBuffer.UV3Kind
  23481. * - VertexBuffer.UV4Kind
  23482. * - VertexBuffer.UV5Kind
  23483. * - VertexBuffer.UV6Kind
  23484. * - VertexBuffer.ColorKind
  23485. * - VertexBuffer.MatricesIndicesKind
  23486. * - VertexBuffer.MatricesIndicesExtraKind
  23487. * - VertexBuffer.MatricesWeightsKind
  23488. * - VertexBuffer.MatricesWeightsExtraKind
  23489. * @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
  23490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23492. */
  23493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23494. /**
  23495. * Returns the mesh VertexBuffer object from the requested `kind`
  23496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23497. * - VertexBuffer.PositionKind
  23498. * - VertexBuffer.NormalKind
  23499. * - VertexBuffer.UVKind
  23500. * - VertexBuffer.UV2Kind
  23501. * - VertexBuffer.UV3Kind
  23502. * - VertexBuffer.UV4Kind
  23503. * - VertexBuffer.UV5Kind
  23504. * - VertexBuffer.UV6Kind
  23505. * - VertexBuffer.ColorKind
  23506. * - VertexBuffer.MatricesIndicesKind
  23507. * - VertexBuffer.MatricesIndicesExtraKind
  23508. * - VertexBuffer.MatricesWeightsKind
  23509. * - VertexBuffer.MatricesWeightsExtraKind
  23510. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23511. */
  23512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23513. /**
  23514. * Tests if a specific vertex buffer is associated with this mesh
  23515. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23516. * - VertexBuffer.PositionKind
  23517. * - VertexBuffer.NormalKind
  23518. * - VertexBuffer.UVKind
  23519. * - VertexBuffer.UV2Kind
  23520. * - VertexBuffer.UV3Kind
  23521. * - VertexBuffer.UV4Kind
  23522. * - VertexBuffer.UV5Kind
  23523. * - VertexBuffer.UV6Kind
  23524. * - VertexBuffer.ColorKind
  23525. * - VertexBuffer.MatricesIndicesKind
  23526. * - VertexBuffer.MatricesIndicesExtraKind
  23527. * - VertexBuffer.MatricesWeightsKind
  23528. * - VertexBuffer.MatricesWeightsExtraKind
  23529. * @returns a boolean
  23530. */
  23531. isVerticesDataPresent(kind: string): boolean;
  23532. /**
  23533. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23535. * - VertexBuffer.PositionKind
  23536. * - VertexBuffer.UVKind
  23537. * - VertexBuffer.UV2Kind
  23538. * - VertexBuffer.UV3Kind
  23539. * - VertexBuffer.UV4Kind
  23540. * - VertexBuffer.UV5Kind
  23541. * - VertexBuffer.UV6Kind
  23542. * - VertexBuffer.ColorKind
  23543. * - VertexBuffer.MatricesIndicesKind
  23544. * - VertexBuffer.MatricesIndicesExtraKind
  23545. * - VertexBuffer.MatricesWeightsKind
  23546. * - VertexBuffer.MatricesWeightsExtraKind
  23547. * @returns a boolean
  23548. */
  23549. isVertexBufferUpdatable(kind: string): boolean;
  23550. /**
  23551. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23553. * - VertexBuffer.PositionKind
  23554. * - VertexBuffer.NormalKind
  23555. * - VertexBuffer.UVKind
  23556. * - VertexBuffer.UV2Kind
  23557. * - VertexBuffer.UV3Kind
  23558. * - VertexBuffer.UV4Kind
  23559. * - VertexBuffer.UV5Kind
  23560. * - VertexBuffer.UV6Kind
  23561. * - VertexBuffer.ColorKind
  23562. * - VertexBuffer.MatricesIndicesKind
  23563. * - VertexBuffer.MatricesIndicesExtraKind
  23564. * - VertexBuffer.MatricesWeightsKind
  23565. * - VertexBuffer.MatricesWeightsExtraKind
  23566. * @returns an array of strings
  23567. */
  23568. getVerticesDataKinds(): string[];
  23569. /**
  23570. * Returns a positive integer : the total number of indices in this mesh geometry.
  23571. * @returns the numner of indices or zero if the mesh has no geometry.
  23572. */
  23573. getTotalIndices(): number;
  23574. /**
  23575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23576. * @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.
  23577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23578. * @returns the indices array or an empty array if the mesh has no geometry
  23579. */
  23580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23581. readonly isBlocked: boolean;
  23582. /**
  23583. * Determine if the current mesh is ready to be rendered
  23584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23585. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23586. * @returns true if all associated assets are ready (material, textures, shaders)
  23587. */
  23588. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23589. /**
  23590. * 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.
  23591. */
  23592. readonly areNormalsFrozen: boolean;
  23593. /**
  23594. * 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.
  23595. * @returns the current mesh
  23596. */
  23597. freezeNormals(): Mesh;
  23598. /**
  23599. * 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
  23600. * @returns the current mesh
  23601. */
  23602. unfreezeNormals(): Mesh;
  23603. /**
  23604. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23605. */
  23606. overridenInstanceCount: number;
  23607. /** @hidden */
  23608. _preActivate(): Mesh;
  23609. /** @hidden */
  23610. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23611. /** @hidden */
  23612. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23613. /**
  23614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23615. * This means the mesh underlying bounding box and sphere are recomputed.
  23616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23617. * @returns the current mesh
  23618. */
  23619. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23620. /** @hidden */
  23621. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23622. /**
  23623. * This function will subdivide the mesh into multiple submeshes
  23624. * @param count defines the expected number of submeshes
  23625. */
  23626. subdivide(count: number): void;
  23627. /**
  23628. * Copy a FloatArray into a specific associated vertex buffer
  23629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23630. * - VertexBuffer.PositionKind
  23631. * - VertexBuffer.UVKind
  23632. * - VertexBuffer.UV2Kind
  23633. * - VertexBuffer.UV3Kind
  23634. * - VertexBuffer.UV4Kind
  23635. * - VertexBuffer.UV5Kind
  23636. * - VertexBuffer.UV6Kind
  23637. * - VertexBuffer.ColorKind
  23638. * - VertexBuffer.MatricesIndicesKind
  23639. * - VertexBuffer.MatricesIndicesExtraKind
  23640. * - VertexBuffer.MatricesWeightsKind
  23641. * - VertexBuffer.MatricesWeightsExtraKind
  23642. * @param data defines the data source
  23643. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23644. * @param stride defines the data stride size (can be null)
  23645. * @returns the current mesh
  23646. */
  23647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23648. /**
  23649. * Flags an associated vertex buffer as updatable
  23650. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23651. * - VertexBuffer.PositionKind
  23652. * - VertexBuffer.UVKind
  23653. * - VertexBuffer.UV2Kind
  23654. * - VertexBuffer.UV3Kind
  23655. * - VertexBuffer.UV4Kind
  23656. * - VertexBuffer.UV5Kind
  23657. * - VertexBuffer.UV6Kind
  23658. * - VertexBuffer.ColorKind
  23659. * - VertexBuffer.MatricesIndicesKind
  23660. * - VertexBuffer.MatricesIndicesExtraKind
  23661. * - VertexBuffer.MatricesWeightsKind
  23662. * - VertexBuffer.MatricesWeightsExtraKind
  23663. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23664. */
  23665. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23666. /**
  23667. * Sets the mesh global Vertex Buffer
  23668. * @param buffer defines the buffer to use
  23669. * @returns the current mesh
  23670. */
  23671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23672. /**
  23673. * Update a specific associated vertex buffer
  23674. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23675. * - VertexBuffer.PositionKind
  23676. * - VertexBuffer.UVKind
  23677. * - VertexBuffer.UV2Kind
  23678. * - VertexBuffer.UV3Kind
  23679. * - VertexBuffer.UV4Kind
  23680. * - VertexBuffer.UV5Kind
  23681. * - VertexBuffer.UV6Kind
  23682. * - VertexBuffer.ColorKind
  23683. * - VertexBuffer.MatricesIndicesKind
  23684. * - VertexBuffer.MatricesIndicesExtraKind
  23685. * - VertexBuffer.MatricesWeightsKind
  23686. * - VertexBuffer.MatricesWeightsExtraKind
  23687. * @param data defines the data source
  23688. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23689. * @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)
  23690. * @returns the current mesh
  23691. */
  23692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23693. /**
  23694. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23696. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23697. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23698. * @returns the current mesh
  23699. */
  23700. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23701. /**
  23702. * Creates a un-shared specific occurence of the geometry for the mesh.
  23703. * @returns the current mesh
  23704. */
  23705. makeGeometryUnique(): Mesh;
  23706. /**
  23707. * Set the index buffer of this mesh
  23708. * @param indices defines the source data
  23709. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23710. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23711. * @returns the current mesh
  23712. */
  23713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23714. /**
  23715. * Update the current index buffer
  23716. * @param indices defines the source data
  23717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23718. * @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)
  23719. * @returns the current mesh
  23720. */
  23721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23722. /**
  23723. * Invert the geometry to move from a right handed system to a left handed one.
  23724. * @returns the current mesh
  23725. */
  23726. toLeftHanded(): Mesh;
  23727. /** @hidden */
  23728. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23729. /** @hidden */
  23730. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23731. /**
  23732. * Registers for this mesh a javascript function called just before the rendering process
  23733. * @param func defines the function to call before rendering this mesh
  23734. * @returns the current mesh
  23735. */
  23736. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23737. /**
  23738. * Disposes a previously registered javascript function called before the rendering
  23739. * @param func defines the function to remove
  23740. * @returns the current mesh
  23741. */
  23742. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23743. /**
  23744. * Registers for this mesh a javascript function called just after the rendering is complete
  23745. * @param func defines the function to call after rendering this mesh
  23746. * @returns the current mesh
  23747. */
  23748. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23749. /**
  23750. * Disposes a previously registered javascript function called after the rendering.
  23751. * @param func defines the function to remove
  23752. * @returns the current mesh
  23753. */
  23754. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23755. /** @hidden */
  23756. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23757. /** @hidden */
  23758. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23759. /** @hidden */
  23760. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23761. /** @hidden */
  23762. _rebuild(): void;
  23763. /** @hidden */
  23764. _freeze(): void;
  23765. /** @hidden */
  23766. _unFreeze(): void;
  23767. /**
  23768. * 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
  23769. * @param subMesh defines the subMesh to render
  23770. * @param enableAlphaMode defines if alpha mode can be changed
  23771. * @returns the current mesh
  23772. */
  23773. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23774. private _onBeforeDraw;
  23775. /**
  23776. * Renormalize the mesh and patch it up if there are no weights
  23777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23778. * However in the case of zero weights then we set just a single influence to 1.
  23779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23780. */
  23781. cleanMatrixWeights(): void;
  23782. private normalizeSkinFourWeights;
  23783. private normalizeSkinWeightsAndExtra;
  23784. /**
  23785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23787. * the user know there was an issue with importing the mesh
  23788. * @returns a validation object with skinned, valid and report string
  23789. */
  23790. validateSkinning(): {
  23791. skinned: boolean;
  23792. valid: boolean;
  23793. report: string;
  23794. };
  23795. /** @hidden */
  23796. _checkDelayState(): Mesh;
  23797. private _queueLoad;
  23798. /**
  23799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23800. * A mesh is in the frustum if its bounding box intersects the frustum
  23801. * @param frustumPlanes defines the frustum to test
  23802. * @returns true if the mesh is in the frustum planes
  23803. */
  23804. isInFrustum(frustumPlanes: Plane[]): boolean;
  23805. /**
  23806. * Sets the mesh material by the material or multiMaterial `id` property
  23807. * @param id is a string identifying the material or the multiMaterial
  23808. * @returns the current mesh
  23809. */
  23810. setMaterialByID(id: string): Mesh;
  23811. /**
  23812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23813. * @returns an array of IAnimatable
  23814. */
  23815. getAnimatables(): IAnimatable[];
  23816. /**
  23817. * Modifies the mesh geometry according to the passed transformation matrix.
  23818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23819. * The mesh normals are modified using the same transformation.
  23820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23821. * @param transform defines the transform matrix to use
  23822. * @see http://doc.babylonjs.com/resources/baking_transformations
  23823. * @returns the current mesh
  23824. */
  23825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23826. /**
  23827. * Modifies the mesh geometry according to its own current World Matrix.
  23828. * The mesh World Matrix is then reset.
  23829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23831. * @see http://doc.babylonjs.com/resources/baking_transformations
  23832. * @returns the current mesh
  23833. */
  23834. bakeCurrentTransformIntoVertices(): Mesh;
  23835. /** @hidden */
  23836. readonly _positions: Nullable<Vector3[]>;
  23837. /** @hidden */
  23838. _resetPointsArrayCache(): Mesh;
  23839. /** @hidden */
  23840. _generatePointsArray(): boolean;
  23841. /**
  23842. * Returns a new Mesh object generated from the current mesh properties.
  23843. * This method must not get confused with createInstance()
  23844. * @param name is a string, the name given to the new mesh
  23845. * @param newParent can be any Node object (default `null`)
  23846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23848. * @returns a new mesh
  23849. */
  23850. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23851. /**
  23852. * Releases resources associated with this mesh.
  23853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23855. */
  23856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23857. /**
  23858. * Modifies the mesh geometry according to a displacement map.
  23859. * 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.
  23860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23861. * @param url is a string, the URL from the image file is to be downloaded.
  23862. * @param minHeight is the lower limit of the displacement.
  23863. * @param maxHeight is the upper limit of the displacement.
  23864. * @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.
  23865. * @param uvOffset is an optional vector2 used to offset UV.
  23866. * @param uvScale is an optional vector2 used to scale UV.
  23867. * @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.
  23868. * @returns the Mesh.
  23869. */
  23870. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23871. /**
  23872. * Modifies the mesh geometry according to a displacementMap buffer.
  23873. * 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.
  23874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23875. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23876. * @param heightMapWidth is the width of the buffer image.
  23877. * @param heightMapHeight is the height of the buffer image.
  23878. * @param minHeight is the lower limit of the displacement.
  23879. * @param maxHeight is the upper limit of the displacement.
  23880. * @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.
  23881. * @param uvOffset is an optional vector2 used to offset UV.
  23882. * @param uvScale is an optional vector2 used to scale UV.
  23883. * @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.
  23884. * @returns the Mesh.
  23885. */
  23886. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23887. /**
  23888. * Modify the mesh to get a flat shading rendering.
  23889. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23890. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23891. * @returns current mesh
  23892. */
  23893. convertToFlatShadedMesh(): Mesh;
  23894. /**
  23895. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23896. * In other words, more vertices, no more indices and a single bigger VBO.
  23897. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23898. * @returns current mesh
  23899. */
  23900. convertToUnIndexedMesh(): Mesh;
  23901. /**
  23902. * Inverses facet orientations.
  23903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23904. * @param flipNormals will also inverts the normals
  23905. * @returns current mesh
  23906. */
  23907. flipFaces(flipNormals?: boolean): Mesh;
  23908. /**
  23909. * Increase the number of facets and hence vertices in a mesh
  23910. * Vertex normals are interpolated from existing vertex normals
  23911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23912. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23913. */
  23914. increaseVertices(numberPerEdge: number): void;
  23915. /**
  23916. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23917. * This will undo any application of covertToFlatShadedMesh
  23918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23919. */
  23920. forceSharedVertices(): void;
  23921. /** @hidden */
  23922. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23923. /** @hidden */
  23924. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23925. /**
  23926. * Creates a new InstancedMesh object from the mesh model.
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23928. * @param name defines the name of the new instance
  23929. * @returns a new InstancedMesh
  23930. */
  23931. createInstance(name: string): InstancedMesh;
  23932. /**
  23933. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23934. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23935. * @returns the current mesh
  23936. */
  23937. synchronizeInstances(): Mesh;
  23938. /**
  23939. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23940. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23941. * This should be used together with the simplification to avoid disappearing triangles.
  23942. * @param successCallback an optional success callback to be called after the optimization finished.
  23943. * @returns the current mesh
  23944. */
  23945. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23946. /**
  23947. * Serialize current mesh
  23948. * @param serializationObject defines the object which will receive the serialization data
  23949. */
  23950. serialize(serializationObject: any): void;
  23951. /** @hidden */
  23952. _syncGeometryWithMorphTargetManager(): void;
  23953. /** @hidden */
  23954. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23955. /**
  23956. * Returns a new Mesh object parsed from the source provided.
  23957. * @param parsedMesh is the source
  23958. * @param scene defines the hosting scene
  23959. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23960. * @returns a new Mesh
  23961. */
  23962. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23963. /**
  23964. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23965. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23966. * @param name defines the name of the mesh to create
  23967. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23968. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23969. * @param closePath creates a seam between the first and the last points of each path of the path array
  23970. * @param offset is taken in account only if the `pathArray` is containing a single path
  23971. * @param scene defines the hosting scene
  23972. * @param updatable defines if the mesh must be flagged as updatable
  23973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23974. * @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)
  23975. * @returns a new Mesh
  23976. */
  23977. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23978. /**
  23979. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23980. * @param name defines the name of the mesh to create
  23981. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23982. * @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
  23983. * @param scene defines the hosting scene
  23984. * @param updatable defines if the mesh must be flagged as updatable
  23985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23986. * @returns a new Mesh
  23987. */
  23988. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23989. /**
  23990. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23991. * @param name defines the name of the mesh to create
  23992. * @param size sets the size (float) of each box side (default 1)
  23993. * @param scene defines the hosting scene
  23994. * @param updatable defines if the mesh must be flagged as updatable
  23995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23996. * @returns a new Mesh
  23997. */
  23998. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23999. /**
  24000. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24001. * @param name defines the name of the mesh to create
  24002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24004. * @param scene defines the hosting scene
  24005. * @param updatable defines if the mesh must be flagged as updatable
  24006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24007. * @returns a new Mesh
  24008. */
  24009. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24010. /**
  24011. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24012. * @param name defines the name of the mesh to create
  24013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24015. * @param scene defines the hosting scene
  24016. * @returns a new Mesh
  24017. */
  24018. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24019. /**
  24020. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24021. * @param name defines the name of the mesh to create
  24022. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24023. * @param diameterTop set the top cap diameter (floats, default 1)
  24024. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24025. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24026. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24027. * @param scene defines the hosting scene
  24028. * @param updatable defines if the mesh must be flagged as updatable
  24029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24030. * @returns a new Mesh
  24031. */
  24032. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24033. /**
  24034. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24035. * @param name defines the name of the mesh to create
  24036. * @param diameter sets the diameter size (float) of the torus (default 1)
  24037. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24038. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24039. * @param scene defines the hosting scene
  24040. * @param updatable defines if the mesh must be flagged as updatable
  24041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24042. * @returns a new Mesh
  24043. */
  24044. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24045. /**
  24046. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24047. * @param name defines the name of the mesh to create
  24048. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24049. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24050. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24051. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24052. * @param p the number of windings on X axis (positive integers, default 2)
  24053. * @param q the number of windings on Y axis (positive integers, default 3)
  24054. * @param scene defines the hosting scene
  24055. * @param updatable defines if the mesh must be flagged as updatable
  24056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24057. * @returns a new Mesh
  24058. */
  24059. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24060. /**
  24061. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24062. * @param name defines the name of the mesh to create
  24063. * @param points is an array successive Vector3
  24064. * @param scene defines the hosting scene
  24065. * @param updatable defines if the mesh must be flagged as updatable
  24066. * @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).
  24067. * @returns a new Mesh
  24068. */
  24069. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24070. /**
  24071. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24072. * @param name defines the name of the mesh to create
  24073. * @param points is an array successive Vector3
  24074. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24075. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24076. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24077. * @param scene defines the hosting scene
  24078. * @param updatable defines if the mesh must be flagged as updatable
  24079. * @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)
  24080. * @returns a new Mesh
  24081. */
  24082. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24083. /**
  24084. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24086. * 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.
  24087. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24088. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24089. * Remember you can only change the shape positions, not their number when updating a polygon.
  24090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24091. * @param name defines the name of the mesh to create
  24092. * @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
  24093. * @param scene defines the hosting scene
  24094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24095. * @param updatable defines if the mesh must be flagged as updatable
  24096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24097. * @param earcutInjection can be used to inject your own earcut reference
  24098. * @returns a new Mesh
  24099. */
  24100. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24101. /**
  24102. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24104. * @param name defines the name of the mesh to create
  24105. * @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
  24106. * @param depth defines the height of extrusion
  24107. * @param scene defines the hosting scene
  24108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24109. * @param updatable defines if the mesh must be flagged as updatable
  24110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24111. * @param earcutInjection can be used to inject your own earcut reference
  24112. * @returns a new Mesh
  24113. */
  24114. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24115. /**
  24116. * Creates an extruded shape mesh.
  24117. * 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
  24118. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24120. * @param name defines the name of the mesh to create
  24121. * @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
  24122. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24123. * @param scale is the value to scale the shape
  24124. * @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
  24125. * @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
  24126. * @param scene defines the hosting scene
  24127. * @param updatable defines if the mesh must be flagged as updatable
  24128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24129. * @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)
  24130. * @returns a new Mesh
  24131. */
  24132. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24133. /**
  24134. * Creates an custom extruded shape mesh.
  24135. * The custom extrusion is a parametric shape.
  24136. * It has no predefined shape. Its final shape will depend on the input parameters.
  24137. * Please consider using the same method from the MeshBuilder class instead
  24138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24139. * @param name defines the name of the mesh to create
  24140. * @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
  24141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24142. * @param scaleFunction is a custom Javascript function called on each path point
  24143. * @param rotationFunction is a custom Javascript function called on each path point
  24144. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24145. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24146. * @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
  24147. * @param scene defines the hosting scene
  24148. * @param updatable defines if the mesh must be flagged as updatable
  24149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24150. * @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)
  24151. * @returns a new Mesh
  24152. */
  24153. 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;
  24154. /**
  24155. * Creates lathe mesh.
  24156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24157. * Please consider using the same method from the MeshBuilder class instead
  24158. * @param name defines the name of the mesh to create
  24159. * @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
  24160. * @param radius is the radius value of the lathe
  24161. * @param tessellation is the side number of the lathe.
  24162. * @param scene defines the hosting scene
  24163. * @param updatable defines if the mesh must be flagged as updatable
  24164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24165. * @returns a new Mesh
  24166. */
  24167. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24168. /**
  24169. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24170. * @param name defines the name of the mesh to create
  24171. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24172. * @param scene defines the hosting scene
  24173. * @param updatable defines if the mesh must be flagged as updatable
  24174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24175. * @returns a new Mesh
  24176. */
  24177. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24178. /**
  24179. * Creates a ground mesh.
  24180. * Please consider using the same method from the MeshBuilder class instead
  24181. * @param name defines the name of the mesh to create
  24182. * @param width set the width of the ground
  24183. * @param height set the height of the ground
  24184. * @param subdivisions sets the number of subdivisions per side
  24185. * @param scene defines the hosting scene
  24186. * @param updatable defines if the mesh must be flagged as updatable
  24187. * @returns a new Mesh
  24188. */
  24189. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24190. /**
  24191. * Creates a tiled ground mesh.
  24192. * Please consider using the same method from the MeshBuilder class instead
  24193. * @param name defines the name of the mesh to create
  24194. * @param xmin set the ground minimum X coordinate
  24195. * @param zmin set the ground minimum Y coordinate
  24196. * @param xmax set the ground maximum X coordinate
  24197. * @param zmax set the ground maximum Z coordinate
  24198. * @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
  24199. * @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
  24200. * @param scene defines the hosting scene
  24201. * @param updatable defines if the mesh must be flagged as updatable
  24202. * @returns a new Mesh
  24203. */
  24204. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24205. w: number;
  24206. h: number;
  24207. }, precision: {
  24208. w: number;
  24209. h: number;
  24210. }, scene: Scene, updatable?: boolean): Mesh;
  24211. /**
  24212. * Creates a ground mesh from a height map.
  24213. * Please consider using the same method from the MeshBuilder class instead
  24214. * @see http://doc.babylonjs.com/babylon101/height_map
  24215. * @param name defines the name of the mesh to create
  24216. * @param url sets the URL of the height map image resource
  24217. * @param width set the ground width size
  24218. * @param height set the ground height size
  24219. * @param subdivisions sets the number of subdivision per side
  24220. * @param minHeight is the minimum altitude on the ground
  24221. * @param maxHeight is the maximum altitude on the ground
  24222. * @param scene defines the hosting scene
  24223. * @param updatable defines if the mesh must be flagged as updatable
  24224. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24225. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24226. * @returns a new Mesh
  24227. */
  24228. 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;
  24229. /**
  24230. * Creates a tube mesh.
  24231. * The tube is a parametric shape.
  24232. * It has no predefined shape. Its final shape will depend on the input parameters.
  24233. * Please consider using the same method from the MeshBuilder class instead
  24234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24235. * @param name defines the name of the mesh to create
  24236. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24237. * @param radius sets the tube radius size
  24238. * @param tessellation is the number of sides on the tubular surface
  24239. * @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
  24240. * @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
  24241. * @param scene defines the hosting scene
  24242. * @param updatable defines if the mesh must be flagged as updatable
  24243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24244. * @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)
  24245. * @returns a new Mesh
  24246. */
  24247. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24248. (i: number, distance: number): number;
  24249. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24250. /**
  24251. * Creates a polyhedron mesh.
  24252. * Please consider using the same method from the MeshBuilder class instead.
  24253. * * 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
  24254. * * The parameter `size` (positive float, default 1) sets the polygon size
  24255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24256. * * 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`
  24257. * * 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
  24258. * * 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)`)
  24259. * * 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
  24260. * * 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
  24261. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24262. * * 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
  24263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24264. * @param name defines the name of the mesh to create
  24265. * @param options defines the options used to create the mesh
  24266. * @param scene defines the hosting scene
  24267. * @returns a new Mesh
  24268. */
  24269. static CreatePolyhedron(name: string, options: {
  24270. type?: number;
  24271. size?: number;
  24272. sizeX?: number;
  24273. sizeY?: number;
  24274. sizeZ?: number;
  24275. custom?: any;
  24276. faceUV?: Vector4[];
  24277. faceColors?: Color4[];
  24278. updatable?: boolean;
  24279. sideOrientation?: number;
  24280. }, scene: Scene): Mesh;
  24281. /**
  24282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24284. * * 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`)
  24285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24286. * * 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
  24287. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24288. * * 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
  24289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24290. * @param name defines the name of the mesh
  24291. * @param options defines the options used to create the mesh
  24292. * @param scene defines the hosting scene
  24293. * @returns a new Mesh
  24294. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24295. */
  24296. static CreateIcoSphere(name: string, options: {
  24297. radius?: number;
  24298. flat?: boolean;
  24299. subdivisions?: number;
  24300. sideOrientation?: number;
  24301. updatable?: boolean;
  24302. }, scene: Scene): Mesh;
  24303. /**
  24304. * Creates a decal mesh.
  24305. * Please consider using the same method from the MeshBuilder class instead.
  24306. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24307. * @param name defines the name of the mesh
  24308. * @param sourceMesh defines the mesh receiving the decal
  24309. * @param position sets the position of the decal in world coordinates
  24310. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24311. * @param size sets the decal scaling
  24312. * @param angle sets the angle to rotate the decal
  24313. * @returns a new Mesh
  24314. */
  24315. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24316. /**
  24317. * Prepare internal position array for software CPU skinning
  24318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24319. */
  24320. setPositionsForCPUSkinning(): Float32Array;
  24321. /**
  24322. * Prepare internal normal array for software CPU skinning
  24323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24324. */
  24325. setNormalsForCPUSkinning(): Float32Array;
  24326. /**
  24327. * Updates the vertex buffer by applying transformation from the bones
  24328. * @param skeleton defines the skeleton to apply to current mesh
  24329. * @returns the current mesh
  24330. */
  24331. applySkeleton(skeleton: Skeleton): Mesh;
  24332. /**
  24333. * 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
  24334. * @param meshes defines the list of meshes to scan
  24335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24336. */
  24337. static MinMax(meshes: AbstractMesh[]): {
  24338. min: Vector3;
  24339. max: Vector3;
  24340. };
  24341. /**
  24342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24344. * @returns a vector3
  24345. */
  24346. static Center(meshesOrMinMaxVector: {
  24347. min: Vector3;
  24348. max: Vector3;
  24349. } | AbstractMesh[]): Vector3;
  24350. /**
  24351. * Merge the array of meshes into a single mesh for performance reasons.
  24352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24358. * @returns a new mesh
  24359. */
  24360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24361. /** @hidden */
  24362. addInstance(instance: InstancedMesh): void;
  24363. /** @hidden */
  24364. removeInstance(instance: InstancedMesh): void;
  24365. }
  24366. }
  24367. declare module BABYLON {
  24368. /**
  24369. * This is the base class of all the camera used in the application.
  24370. * @see http://doc.babylonjs.com/features/cameras
  24371. */
  24372. export class Camera extends Node {
  24373. /** @hidden */
  24374. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24375. /**
  24376. * This is the default projection mode used by the cameras.
  24377. * It helps recreating a feeling of perspective and better appreciate depth.
  24378. * This is the best way to simulate real life cameras.
  24379. */
  24380. static readonly PERSPECTIVE_CAMERA: number;
  24381. /**
  24382. * This helps creating camera with an orthographic mode.
  24383. * 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.
  24384. */
  24385. static readonly ORTHOGRAPHIC_CAMERA: number;
  24386. /**
  24387. * This is the default FOV mode for perspective cameras.
  24388. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24389. */
  24390. static readonly FOVMODE_VERTICAL_FIXED: number;
  24391. /**
  24392. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24393. */
  24394. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24395. /**
  24396. * This specifies ther is no need for a camera rig.
  24397. * Basically only one eye is rendered corresponding to the camera.
  24398. */
  24399. static readonly RIG_MODE_NONE: number;
  24400. /**
  24401. * Simulates a camera Rig with one blue eye and one red eye.
  24402. * This can be use with 3d blue and red glasses.
  24403. */
  24404. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24405. /**
  24406. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24407. */
  24408. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24409. /**
  24410. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24411. */
  24412. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24413. /**
  24414. * Defines that both eyes of the camera will be rendered over under each other.
  24415. */
  24416. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24417. /**
  24418. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24419. */
  24420. static readonly RIG_MODE_VR: number;
  24421. /**
  24422. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24423. */
  24424. static readonly RIG_MODE_WEBVR: number;
  24425. /**
  24426. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24427. */
  24428. static readonly RIG_MODE_CUSTOM: number;
  24429. /**
  24430. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24431. */
  24432. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24433. /**
  24434. * Define the input manager associated with the camera.
  24435. */
  24436. inputs: CameraInputsManager<Camera>;
  24437. /** @hidden */
  24438. _position: Vector3;
  24439. /**
  24440. * Define the current local position of the camera in the scene
  24441. */
  24442. position: Vector3;
  24443. /**
  24444. * The vector the camera should consider as up.
  24445. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24446. */
  24447. upVector: Vector3;
  24448. /**
  24449. * Define the current limit on the left side for an orthographic camera
  24450. * In scene unit
  24451. */
  24452. orthoLeft: Nullable<number>;
  24453. /**
  24454. * Define the current limit on the right side for an orthographic camera
  24455. * In scene unit
  24456. */
  24457. orthoRight: Nullable<number>;
  24458. /**
  24459. * Define the current limit on the bottom side for an orthographic camera
  24460. * In scene unit
  24461. */
  24462. orthoBottom: Nullable<number>;
  24463. /**
  24464. * Define the current limit on the top side for an orthographic camera
  24465. * In scene unit
  24466. */
  24467. orthoTop: Nullable<number>;
  24468. /**
  24469. * Field Of View is set in Radians. (default is 0.8)
  24470. */
  24471. fov: number;
  24472. /**
  24473. * Define the minimum distance the camera can see from.
  24474. * This is important to note that the depth buffer are not infinite and the closer it starts
  24475. * the more your scene might encounter depth fighting issue.
  24476. */
  24477. minZ: number;
  24478. /**
  24479. * Define the maximum distance the camera can see to.
  24480. * This is important to note that the depth buffer are not infinite and the further it end
  24481. * the more your scene might encounter depth fighting issue.
  24482. */
  24483. maxZ: number;
  24484. /**
  24485. * Define the default inertia of the camera.
  24486. * This helps giving a smooth feeling to the camera movement.
  24487. */
  24488. inertia: number;
  24489. /**
  24490. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24491. */
  24492. mode: number;
  24493. /**
  24494. * Define wether the camera is intermediate.
  24495. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24496. */
  24497. isIntermediate: boolean;
  24498. /**
  24499. * Define the viewport of the camera.
  24500. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24501. */
  24502. viewport: Viewport;
  24503. /**
  24504. * Restricts the camera to viewing objects with the same layerMask.
  24505. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24506. */
  24507. layerMask: number;
  24508. /**
  24509. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24510. */
  24511. fovMode: number;
  24512. /**
  24513. * Rig mode of the camera.
  24514. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24515. * This is normally controlled byt the camera themselves as internal use.
  24516. */
  24517. cameraRigMode: number;
  24518. /**
  24519. * Defines the distance between both "eyes" in case of a RIG
  24520. */
  24521. interaxialDistance: number;
  24522. /**
  24523. * Defines if stereoscopic rendering is done side by side or over under.
  24524. */
  24525. isStereoscopicSideBySide: boolean;
  24526. /**
  24527. * 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
  24528. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24529. * else in the scene. (Eg. security camera)
  24530. *
  24531. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24532. */
  24533. customRenderTargets: RenderTargetTexture[];
  24534. /**
  24535. * When set, the camera will render to this render target instead of the default canvas
  24536. *
  24537. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24538. */
  24539. outputRenderTarget: Nullable<RenderTargetTexture>;
  24540. /**
  24541. * Observable triggered when the camera view matrix has changed.
  24542. */
  24543. onViewMatrixChangedObservable: Observable<Camera>;
  24544. /**
  24545. * Observable triggered when the camera Projection matrix has changed.
  24546. */
  24547. onProjectionMatrixChangedObservable: Observable<Camera>;
  24548. /**
  24549. * Observable triggered when the inputs have been processed.
  24550. */
  24551. onAfterCheckInputsObservable: Observable<Camera>;
  24552. /**
  24553. * Observable triggered when reset has been called and applied to the camera.
  24554. */
  24555. onRestoreStateObservable: Observable<Camera>;
  24556. /** @hidden */
  24557. _cameraRigParams: any;
  24558. /** @hidden */
  24559. _rigCameras: Camera[];
  24560. /** @hidden */
  24561. _rigPostProcess: Nullable<PostProcess>;
  24562. protected _webvrViewMatrix: Matrix;
  24563. /** @hidden */
  24564. _skipRendering: boolean;
  24565. /** @hidden */
  24566. _projectionMatrix: Matrix;
  24567. /** @hidden */
  24568. _postProcesses: Nullable<PostProcess>[];
  24569. /** @hidden */
  24570. _activeMeshes: SmartArray<AbstractMesh>;
  24571. protected _globalPosition: Vector3;
  24572. /** @hidden */
  24573. _computedViewMatrix: Matrix;
  24574. private _doNotComputeProjectionMatrix;
  24575. private _transformMatrix;
  24576. private _frustumPlanes;
  24577. private _refreshFrustumPlanes;
  24578. private _storedFov;
  24579. private _stateStored;
  24580. /**
  24581. * Instantiates a new camera object.
  24582. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24583. * @see http://doc.babylonjs.com/features/cameras
  24584. * @param name Defines the name of the camera in the scene
  24585. * @param position Defines the position of the camera
  24586. * @param scene Defines the scene the camera belongs too
  24587. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24588. */
  24589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24590. /**
  24591. * Store current camera state (fov, position, etc..)
  24592. * @returns the camera
  24593. */
  24594. storeState(): Camera;
  24595. /**
  24596. * Restores the camera state values if it has been stored. You must call storeState() first
  24597. */
  24598. protected _restoreStateValues(): boolean;
  24599. /**
  24600. * Restored camera state. You must call storeState() first.
  24601. * @returns true if restored and false otherwise
  24602. */
  24603. restoreState(): boolean;
  24604. /**
  24605. * Gets the class name of the camera.
  24606. * @returns the class name
  24607. */
  24608. getClassName(): string;
  24609. /** @hidden */
  24610. readonly _isCamera: boolean;
  24611. /**
  24612. * Gets a string representation of the camera useful for debug purpose.
  24613. * @param fullDetails Defines that a more verboe level of logging is required
  24614. * @returns the string representation
  24615. */
  24616. toString(fullDetails?: boolean): string;
  24617. /**
  24618. * Gets the current world space position of the camera.
  24619. */
  24620. readonly globalPosition: Vector3;
  24621. /**
  24622. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24623. * @returns the active meshe list
  24624. */
  24625. getActiveMeshes(): SmartArray<AbstractMesh>;
  24626. /**
  24627. * Check wether a mesh is part of the current active mesh list of the camera
  24628. * @param mesh Defines the mesh to check
  24629. * @returns true if active, false otherwise
  24630. */
  24631. isActiveMesh(mesh: Mesh): boolean;
  24632. /**
  24633. * Is this camera ready to be used/rendered
  24634. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24635. * @return true if the camera is ready
  24636. */
  24637. isReady(completeCheck?: boolean): boolean;
  24638. /** @hidden */
  24639. _initCache(): void;
  24640. /** @hidden */
  24641. _updateCache(ignoreParentClass?: boolean): void;
  24642. /** @hidden */
  24643. _isSynchronized(): boolean;
  24644. /** @hidden */
  24645. _isSynchronizedViewMatrix(): boolean;
  24646. /** @hidden */
  24647. _isSynchronizedProjectionMatrix(): boolean;
  24648. /**
  24649. * Attach the input controls to a specific dom element to get the input from.
  24650. * @param element Defines the element the controls should be listened from
  24651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24652. */
  24653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24654. /**
  24655. * Detach the current controls from the specified dom element.
  24656. * @param element Defines the element to stop listening the inputs from
  24657. */
  24658. detachControl(element: HTMLElement): void;
  24659. /**
  24660. * Update the camera state according to the different inputs gathered during the frame.
  24661. */
  24662. update(): void;
  24663. /** @hidden */
  24664. _checkInputs(): void;
  24665. /** @hidden */
  24666. readonly rigCameras: Camera[];
  24667. /**
  24668. * Gets the post process used by the rig cameras
  24669. */
  24670. readonly rigPostProcess: Nullable<PostProcess>;
  24671. /**
  24672. * Internal, gets the first post proces.
  24673. * @returns the first post process to be run on this camera.
  24674. */
  24675. _getFirstPostProcess(): Nullable<PostProcess>;
  24676. private _cascadePostProcessesToRigCams;
  24677. /**
  24678. * Attach a post process to the camera.
  24679. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24680. * @param postProcess The post process to attach to the camera
  24681. * @param insertAt The position of the post process in case several of them are in use in the scene
  24682. * @returns the position the post process has been inserted at
  24683. */
  24684. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24685. /**
  24686. * Detach a post process to the camera.
  24687. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24688. * @param postProcess The post process to detach from the camera
  24689. */
  24690. detachPostProcess(postProcess: PostProcess): void;
  24691. /**
  24692. * Gets the current world matrix of the camera
  24693. */
  24694. getWorldMatrix(): Matrix;
  24695. /** @hidden */
  24696. _getViewMatrix(): Matrix;
  24697. /**
  24698. * Gets the current view matrix of the camera.
  24699. * @param force forces the camera to recompute the matrix without looking at the cached state
  24700. * @returns the view matrix
  24701. */
  24702. getViewMatrix(force?: boolean): Matrix;
  24703. /**
  24704. * Freeze the projection matrix.
  24705. * It will prevent the cache check of the camera projection compute and can speed up perf
  24706. * if no parameter of the camera are meant to change
  24707. * @param projection Defines manually a projection if necessary
  24708. */
  24709. freezeProjectionMatrix(projection?: Matrix): void;
  24710. /**
  24711. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24712. */
  24713. unfreezeProjectionMatrix(): void;
  24714. /**
  24715. * Gets the current projection matrix of the camera.
  24716. * @param force forces the camera to recompute the matrix without looking at the cached state
  24717. * @returns the projection matrix
  24718. */
  24719. getProjectionMatrix(force?: boolean): Matrix;
  24720. /**
  24721. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24722. * @returns a Matrix
  24723. */
  24724. getTransformationMatrix(): Matrix;
  24725. private _updateFrustumPlanes;
  24726. /**
  24727. * Checks if a cullable object (mesh...) is in the camera frustum
  24728. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24729. * @param target The object to check
  24730. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24731. * @returns true if the object is in frustum otherwise false
  24732. */
  24733. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24734. /**
  24735. * Checks if a cullable object (mesh...) is in the camera frustum
  24736. * Unlike isInFrustum this cheks the full bounding box
  24737. * @param target The object to check
  24738. * @returns true if the object is in frustum otherwise false
  24739. */
  24740. isCompletelyInFrustum(target: ICullable): boolean;
  24741. /**
  24742. * Gets a ray in the forward direction from the camera.
  24743. * @param length Defines the length of the ray to create
  24744. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24745. * @param origin Defines the start point of the ray which defaults to the camera position
  24746. * @returns the forward ray
  24747. */
  24748. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24749. /**
  24750. * Releases resources associated with this node.
  24751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24753. */
  24754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24755. /** @hidden */
  24756. _isLeftCamera: boolean;
  24757. /**
  24758. * Gets the left camera of a rig setup in case of Rigged Camera
  24759. */
  24760. readonly isLeftCamera: boolean;
  24761. /** @hidden */
  24762. _isRightCamera: boolean;
  24763. /**
  24764. * Gets the right camera of a rig setup in case of Rigged Camera
  24765. */
  24766. readonly isRightCamera: boolean;
  24767. /**
  24768. * Gets the left camera of a rig setup in case of Rigged Camera
  24769. */
  24770. readonly leftCamera: Nullable<FreeCamera>;
  24771. /**
  24772. * Gets the right camera of a rig setup in case of Rigged Camera
  24773. */
  24774. readonly rightCamera: Nullable<FreeCamera>;
  24775. /**
  24776. * Gets the left camera target of a rig setup in case of Rigged Camera
  24777. * @returns the target position
  24778. */
  24779. getLeftTarget(): Nullable<Vector3>;
  24780. /**
  24781. * Gets the right camera target of a rig setup in case of Rigged Camera
  24782. * @returns the target position
  24783. */
  24784. getRightTarget(): Nullable<Vector3>;
  24785. /**
  24786. * @hidden
  24787. */
  24788. setCameraRigMode(mode: number, rigParams: any): void;
  24789. /** @hidden */
  24790. static _setStereoscopicRigMode(camera: Camera): void;
  24791. /** @hidden */
  24792. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24793. /** @hidden */
  24794. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24795. /** @hidden */
  24796. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24797. /** @hidden */
  24798. _getVRProjectionMatrix(): Matrix;
  24799. protected _updateCameraRotationMatrix(): void;
  24800. protected _updateWebVRCameraRotationMatrix(): void;
  24801. /**
  24802. * This function MUST be overwritten by the different WebVR cameras available.
  24803. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24804. * @hidden
  24805. */
  24806. _getWebVRProjectionMatrix(): Matrix;
  24807. /**
  24808. * This function MUST be overwritten by the different WebVR cameras available.
  24809. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24810. * @hidden
  24811. */
  24812. _getWebVRViewMatrix(): Matrix;
  24813. /** @hidden */
  24814. setCameraRigParameter(name: string, value: any): void;
  24815. /**
  24816. * needs to be overridden by children so sub has required properties to be copied
  24817. * @hidden
  24818. */
  24819. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24820. /**
  24821. * May need to be overridden by children
  24822. * @hidden
  24823. */
  24824. _updateRigCameras(): void;
  24825. /** @hidden */
  24826. _setupInputs(): void;
  24827. /**
  24828. * Serialiaze the camera setup to a json represention
  24829. * @returns the JSON representation
  24830. */
  24831. serialize(): any;
  24832. /**
  24833. * Clones the current camera.
  24834. * @param name The cloned camera name
  24835. * @returns the cloned camera
  24836. */
  24837. clone(name: string): Camera;
  24838. /**
  24839. * Gets the direction of the camera relative to a given local axis.
  24840. * @param localAxis Defines the reference axis to provide a relative direction.
  24841. * @return the direction
  24842. */
  24843. getDirection(localAxis: Vector3): Vector3;
  24844. /**
  24845. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24846. * @param localAxis Defines the reference axis to provide a relative direction.
  24847. * @param result Defines the vector to store the result in
  24848. */
  24849. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24850. /**
  24851. * Gets a camera constructor for a given camera type
  24852. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24853. * @param name The name of the camera the result will be able to instantiate
  24854. * @param scene The scene the result will construct the camera in
  24855. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24856. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24857. * @returns a factory method to construc the camera
  24858. */
  24859. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24860. /**
  24861. * Compute the world matrix of the camera.
  24862. * @returns the camera workd matrix
  24863. */
  24864. computeWorldMatrix(): Matrix;
  24865. /**
  24866. * Parse a JSON and creates the camera from the parsed information
  24867. * @param parsedCamera The JSON to parse
  24868. * @param scene The scene to instantiate the camera in
  24869. * @returns the newly constructed camera
  24870. */
  24871. static Parse(parsedCamera: any, scene: Scene): Camera;
  24872. }
  24873. }
  24874. declare module BABYLON {
  24875. /**
  24876. * Class containing static functions to help procedurally build meshes
  24877. */
  24878. export class DiscBuilder {
  24879. /**
  24880. * Creates a plane polygonal mesh. By default, this is a disc
  24881. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24882. * * 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
  24883. * * 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
  24884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24885. * * 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
  24886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24887. * @param name defines the name of the mesh
  24888. * @param options defines the options used to create the mesh
  24889. * @param scene defines the hosting scene
  24890. * @returns the plane polygonal mesh
  24891. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24892. */
  24893. static CreateDisc(name: string, options: {
  24894. radius?: number;
  24895. tessellation?: number;
  24896. arc?: number;
  24897. updatable?: boolean;
  24898. sideOrientation?: number;
  24899. frontUVs?: Vector4;
  24900. backUVs?: Vector4;
  24901. }, scene?: Nullable<Scene>): Mesh;
  24902. }
  24903. }
  24904. declare module BABYLON {
  24905. /**
  24906. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24907. *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.
  24908. * The SPS is also a particle system. It provides some methods to manage the particles.
  24909. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24910. *
  24911. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24912. */
  24913. export class SolidParticleSystem implements IDisposable {
  24914. /**
  24915. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24916. * Example : var p = SPS.particles[i];
  24917. */
  24918. particles: SolidParticle[];
  24919. /**
  24920. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24921. */
  24922. nbParticles: number;
  24923. /**
  24924. * If the particles must ever face the camera (default false). Useful for planar particles.
  24925. */
  24926. billboard: boolean;
  24927. /**
  24928. * Recompute normals when adding a shape
  24929. */
  24930. recomputeNormals: boolean;
  24931. /**
  24932. * This a counter ofr your own usage. It's not set by any SPS functions.
  24933. */
  24934. counter: number;
  24935. /**
  24936. * The SPS name. This name is also given to the underlying mesh.
  24937. */
  24938. name: string;
  24939. /**
  24940. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24941. */
  24942. mesh: Mesh;
  24943. /**
  24944. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24945. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24946. */
  24947. vars: any;
  24948. /**
  24949. * This array is populated when the SPS is set as 'pickable'.
  24950. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24951. * Each element of this array is an object `{idx: int, faceId: int}`.
  24952. * `idx` is the picked particle index in the `SPS.particles` array
  24953. * `faceId` is the picked face index counted within this particle.
  24954. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24955. */
  24956. pickedParticles: {
  24957. idx: number;
  24958. faceId: number;
  24959. }[];
  24960. /**
  24961. * This array is populated when `enableDepthSort` is set to true.
  24962. * Each element of this array is an instance of the class DepthSortedParticle.
  24963. */
  24964. depthSortedParticles: DepthSortedParticle[];
  24965. /**
  24966. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24967. * @hidden
  24968. */
  24969. _bSphereOnly: boolean;
  24970. /**
  24971. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24972. * @hidden
  24973. */
  24974. _bSphereRadiusFactor: number;
  24975. private _scene;
  24976. private _positions;
  24977. private _indices;
  24978. private _normals;
  24979. private _colors;
  24980. private _uvs;
  24981. private _indices32;
  24982. private _positions32;
  24983. private _normals32;
  24984. private _fixedNormal32;
  24985. private _colors32;
  24986. private _uvs32;
  24987. private _index;
  24988. private _updatable;
  24989. private _pickable;
  24990. private _isVisibilityBoxLocked;
  24991. private _alwaysVisible;
  24992. private _depthSort;
  24993. private _shapeCounter;
  24994. private _copy;
  24995. private _color;
  24996. private _computeParticleColor;
  24997. private _computeParticleTexture;
  24998. private _computeParticleRotation;
  24999. private _computeParticleVertex;
  25000. private _computeBoundingBox;
  25001. private _depthSortParticles;
  25002. private _camera;
  25003. private _mustUnrotateFixedNormals;
  25004. private _particlesIntersect;
  25005. private _needs32Bits;
  25006. /**
  25007. * Creates a SPS (Solid Particle System) object.
  25008. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25009. * @param scene (Scene) is the scene in which the SPS is added.
  25010. * @param options defines the options of the sps e.g.
  25011. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25012. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25013. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25014. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25015. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25016. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25017. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25018. */
  25019. constructor(name: string, scene: Scene, options?: {
  25020. updatable?: boolean;
  25021. isPickable?: boolean;
  25022. enableDepthSort?: boolean;
  25023. particleIntersection?: boolean;
  25024. boundingSphereOnly?: boolean;
  25025. bSphereRadiusFactor?: number;
  25026. });
  25027. /**
  25028. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25029. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25030. * @returns the created mesh
  25031. */
  25032. buildMesh(): Mesh;
  25033. /**
  25034. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25035. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25036. * Thus the particles generated from `digest()` have their property `position` set yet.
  25037. * @param mesh ( Mesh ) is the mesh to be digested
  25038. * @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
  25039. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25040. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25041. * @returns the current SPS
  25042. */
  25043. digest(mesh: Mesh, options?: {
  25044. facetNb?: number;
  25045. number?: number;
  25046. delta?: number;
  25047. }): SolidParticleSystem;
  25048. private _unrotateFixedNormals;
  25049. private _resetCopy;
  25050. private _meshBuilder;
  25051. private _posToShape;
  25052. private _uvsToShapeUV;
  25053. private _addParticle;
  25054. /**
  25055. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25056. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25057. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25058. * @param nb (positive integer) the number of particles to be created from this model
  25059. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25060. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25061. * @returns the number of shapes in the system
  25062. */
  25063. addShape(mesh: Mesh, nb: number, options?: {
  25064. positionFunction?: any;
  25065. vertexFunction?: any;
  25066. }): number;
  25067. private _rebuildParticle;
  25068. /**
  25069. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25070. * @returns the SPS.
  25071. */
  25072. rebuildMesh(): SolidParticleSystem;
  25073. /**
  25074. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25075. * This method calls `updateParticle()` for each particle of the SPS.
  25076. * For an animated SPS, it is usually called within the render loop.
  25077. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25078. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25079. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25080. * @returns the SPS.
  25081. */
  25082. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25083. /**
  25084. * Disposes the SPS.
  25085. */
  25086. dispose(): void;
  25087. /**
  25088. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25090. * @returns the SPS.
  25091. */
  25092. refreshVisibleSize(): SolidParticleSystem;
  25093. /**
  25094. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25095. * @param size the size (float) of the visibility box
  25096. * note : this doesn't lock the SPS mesh bounding box.
  25097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25098. */
  25099. setVisibilityBox(size: number): void;
  25100. /**
  25101. * Gets whether the SPS as always visible or not
  25102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25103. */
  25104. /**
  25105. * Sets the SPS as always visible or not
  25106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25107. */
  25108. isAlwaysVisible: boolean;
  25109. /**
  25110. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25112. */
  25113. /**
  25114. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25115. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25116. */
  25117. isVisibilityBoxLocked: boolean;
  25118. /**
  25119. * Tells to `setParticles()` to compute the particle rotations or not.
  25120. * Default value : true. The SPS is faster when it's set to false.
  25121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25122. */
  25123. /**
  25124. * Gets if `setParticles()` computes the particle rotations or not.
  25125. * Default value : true. The SPS is faster when it's set to false.
  25126. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25127. */
  25128. computeParticleRotation: boolean;
  25129. /**
  25130. * Tells to `setParticles()` to compute the particle colors or not.
  25131. * Default value : true. The SPS is faster when it's set to false.
  25132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25133. */
  25134. /**
  25135. * Gets if `setParticles()` computes the particle colors or not.
  25136. * Default value : true. The SPS is faster when it's set to false.
  25137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25138. */
  25139. computeParticleColor: boolean;
  25140. /**
  25141. * Gets if `setParticles()` computes the particle textures or not.
  25142. * Default value : true. The SPS is faster when it's set to false.
  25143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25144. */
  25145. computeParticleTexture: boolean;
  25146. /**
  25147. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25148. * Default value : false. The SPS is faster when it's set to false.
  25149. * Note : the particle custom vertex positions aren't stored values.
  25150. */
  25151. /**
  25152. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25153. * Default value : false. The SPS is faster when it's set to false.
  25154. * Note : the particle custom vertex positions aren't stored values.
  25155. */
  25156. computeParticleVertex: boolean;
  25157. /**
  25158. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25159. */
  25160. /**
  25161. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25162. */
  25163. computeBoundingBox: boolean;
  25164. /**
  25165. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25166. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25167. * Default : `true`
  25168. */
  25169. /**
  25170. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25171. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25172. * Default : `true`
  25173. */
  25174. depthSortParticles: boolean;
  25175. /**
  25176. * This function does nothing. It may be overwritten to set all the particle first values.
  25177. * The SPS doesn't call this function, you may have to call it by your own.
  25178. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25179. */
  25180. initParticles(): void;
  25181. /**
  25182. * This function does nothing. It may be overwritten to recycle a particle.
  25183. * The SPS doesn't call this function, you may have to call it by your own.
  25184. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25185. * @param particle The particle to recycle
  25186. * @returns the recycled particle
  25187. */
  25188. recycleParticle(particle: SolidParticle): SolidParticle;
  25189. /**
  25190. * Updates a particle : this function should be overwritten by the user.
  25191. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25193. * @example : just set a particle position or velocity and recycle conditions
  25194. * @param particle The particle to update
  25195. * @returns the updated particle
  25196. */
  25197. updateParticle(particle: SolidParticle): SolidParticle;
  25198. /**
  25199. * Updates a vertex of a particle : it can be overwritten by the user.
  25200. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25201. * @param particle the current particle
  25202. * @param vertex the current index of the current particle
  25203. * @param pt the index of the current vertex in the particle shape
  25204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25205. * @example : just set a vertex particle position
  25206. * @returns the updated vertex
  25207. */
  25208. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25209. /**
  25210. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25211. * This does nothing and may be overwritten by the user.
  25212. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25213. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25214. * @param update the boolean update value actually passed to setParticles()
  25215. */
  25216. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25217. /**
  25218. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25219. * This will be passed three parameters.
  25220. * This does nothing and may be overwritten by the user.
  25221. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25222. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25223. * @param update the boolean update value actually passed to setParticles()
  25224. */
  25225. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25226. }
  25227. }
  25228. declare module BABYLON {
  25229. /**
  25230. * Represents one particle of a solid particle system.
  25231. */
  25232. export class SolidParticle {
  25233. /**
  25234. * particle global index
  25235. */
  25236. idx: number;
  25237. /**
  25238. * The color of the particle
  25239. */
  25240. color: Nullable<Color4>;
  25241. /**
  25242. * The world space position of the particle.
  25243. */
  25244. position: Vector3;
  25245. /**
  25246. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25247. */
  25248. rotation: Vector3;
  25249. /**
  25250. * The world space rotation quaternion of the particle.
  25251. */
  25252. rotationQuaternion: Nullable<Quaternion>;
  25253. /**
  25254. * The scaling of the particle.
  25255. */
  25256. scaling: Vector3;
  25257. /**
  25258. * The uvs of the particle.
  25259. */
  25260. uvs: Vector4;
  25261. /**
  25262. * The current speed of the particle.
  25263. */
  25264. velocity: Vector3;
  25265. /**
  25266. * The pivot point in the particle local space.
  25267. */
  25268. pivot: Vector3;
  25269. /**
  25270. * Must the particle be translated from its pivot point in its local space ?
  25271. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25272. * Default : false
  25273. */
  25274. translateFromPivot: boolean;
  25275. /**
  25276. * Is the particle active or not ?
  25277. */
  25278. alive: boolean;
  25279. /**
  25280. * Is the particle visible or not ?
  25281. */
  25282. isVisible: boolean;
  25283. /**
  25284. * Index of this particle in the global "positions" array (Internal use)
  25285. * @hidden
  25286. */
  25287. _pos: number;
  25288. /**
  25289. * @hidden Index of this particle in the global "indices" array (Internal use)
  25290. */
  25291. _ind: number;
  25292. /**
  25293. * @hidden ModelShape of this particle (Internal use)
  25294. */
  25295. _model: ModelShape;
  25296. /**
  25297. * ModelShape id of this particle
  25298. */
  25299. shapeId: number;
  25300. /**
  25301. * Index of the particle in its shape id (Internal use)
  25302. */
  25303. idxInShape: number;
  25304. /**
  25305. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25306. */
  25307. _modelBoundingInfo: BoundingInfo;
  25308. /**
  25309. * @hidden Particle BoundingInfo object (Internal use)
  25310. */
  25311. _boundingInfo: BoundingInfo;
  25312. /**
  25313. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25314. */
  25315. _sps: SolidParticleSystem;
  25316. /**
  25317. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25318. */
  25319. _stillInvisible: boolean;
  25320. /**
  25321. * @hidden Last computed particle rotation matrix
  25322. */
  25323. _rotationMatrix: number[];
  25324. /**
  25325. * Parent particle Id, if any.
  25326. * Default null.
  25327. */
  25328. parentId: Nullable<number>;
  25329. /**
  25330. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25331. * The possible values are :
  25332. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25333. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25334. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25335. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25336. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25337. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25338. * */
  25339. cullingStrategy: number;
  25340. /**
  25341. * @hidden Internal global position in the SPS.
  25342. */
  25343. _globalPosition: Vector3;
  25344. /**
  25345. * Creates a Solid Particle object.
  25346. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25347. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25348. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25349. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25350. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25351. * @param shapeId (integer) is the model shape identifier in the SPS.
  25352. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25353. * @param sps defines the sps it is associated to
  25354. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25355. */
  25356. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25357. /**
  25358. * Legacy support, changed scale to scaling
  25359. */
  25360. /**
  25361. * Legacy support, changed scale to scaling
  25362. */
  25363. scale: Vector3;
  25364. /**
  25365. * Legacy support, changed quaternion to rotationQuaternion
  25366. */
  25367. /**
  25368. * Legacy support, changed quaternion to rotationQuaternion
  25369. */
  25370. quaternion: Nullable<Quaternion>;
  25371. /**
  25372. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25373. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25374. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25375. * @returns true if it intersects
  25376. */
  25377. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25378. /**
  25379. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25380. * A particle is in the frustum if its bounding box intersects the frustum
  25381. * @param frustumPlanes defines the frustum to test
  25382. * @returns true if the particle is in the frustum planes
  25383. */
  25384. isInFrustum(frustumPlanes: Plane[]): boolean;
  25385. /**
  25386. * get the rotation matrix of the particle
  25387. * @hidden
  25388. */
  25389. getRotationMatrix(m: Matrix): void;
  25390. }
  25391. /**
  25392. * Represents the shape of the model used by one particle of a solid particle system.
  25393. * SPS internal tool, don't use it manually.
  25394. */
  25395. export class ModelShape {
  25396. /**
  25397. * The shape id
  25398. * @hidden
  25399. */
  25400. shapeID: number;
  25401. /**
  25402. * flat array of model positions (internal use)
  25403. * @hidden
  25404. */
  25405. _shape: Vector3[];
  25406. /**
  25407. * flat array of model UVs (internal use)
  25408. * @hidden
  25409. */
  25410. _shapeUV: number[];
  25411. /**
  25412. * length of the shape in the model indices array (internal use)
  25413. * @hidden
  25414. */
  25415. _indicesLength: number;
  25416. /**
  25417. * Custom position function (internal use)
  25418. * @hidden
  25419. */
  25420. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25421. /**
  25422. * Custom vertex function (internal use)
  25423. * @hidden
  25424. */
  25425. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25426. /**
  25427. * 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.
  25428. * SPS internal tool, don't use it manually.
  25429. * @hidden
  25430. */
  25431. 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>);
  25432. }
  25433. /**
  25434. * Represents a Depth Sorted Particle in the solid particle system.
  25435. */
  25436. export class DepthSortedParticle {
  25437. /**
  25438. * Index of the particle in the "indices" array
  25439. */
  25440. ind: number;
  25441. /**
  25442. * Length of the particle shape in the "indices" array
  25443. */
  25444. indicesLength: number;
  25445. /**
  25446. * Squared distance from the particle to the camera
  25447. */
  25448. sqDistance: number;
  25449. }
  25450. }
  25451. declare module BABYLON {
  25452. /**
  25453. * @hidden
  25454. */
  25455. export class _MeshCollisionData {
  25456. _checkCollisions: boolean;
  25457. _collisionMask: number;
  25458. _collisionGroup: number;
  25459. _collider: Nullable<Collider>;
  25460. _oldPositionForCollisions: Vector3;
  25461. _diffPositionForCollisions: Vector3;
  25462. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25463. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25464. }
  25465. }
  25466. declare module BABYLON {
  25467. /** @hidden */
  25468. class _FacetDataStorage {
  25469. facetPositions: Vector3[];
  25470. facetNormals: Vector3[];
  25471. facetPartitioning: number[][];
  25472. facetNb: number;
  25473. partitioningSubdivisions: number;
  25474. partitioningBBoxRatio: number;
  25475. facetDataEnabled: boolean;
  25476. facetParameters: any;
  25477. bbSize: Vector3;
  25478. subDiv: {
  25479. max: number;
  25480. X: number;
  25481. Y: number;
  25482. Z: number;
  25483. };
  25484. facetDepthSort: boolean;
  25485. facetDepthSortEnabled: boolean;
  25486. depthSortedIndices: IndicesArray;
  25487. depthSortedFacets: {
  25488. ind: number;
  25489. sqDistance: number;
  25490. }[];
  25491. facetDepthSortFunction: (f1: {
  25492. ind: number;
  25493. sqDistance: number;
  25494. }, f2: {
  25495. ind: number;
  25496. sqDistance: number;
  25497. }) => number;
  25498. facetDepthSortFrom: Vector3;
  25499. facetDepthSortOrigin: Vector3;
  25500. invertedMatrix: Matrix;
  25501. }
  25502. /**
  25503. * @hidden
  25504. **/
  25505. class _InternalAbstractMeshDataInfo {
  25506. _hasVertexAlpha: boolean;
  25507. _useVertexColors: boolean;
  25508. _numBoneInfluencers: number;
  25509. _applyFog: boolean;
  25510. _receiveShadows: boolean;
  25511. _facetData: _FacetDataStorage;
  25512. _visibility: number;
  25513. _skeleton: Nullable<Skeleton>;
  25514. _layerMask: number;
  25515. _computeBonesUsingShaders: boolean;
  25516. _isActive: boolean;
  25517. _onlyForInstances: boolean;
  25518. _isActiveIntermediate: boolean;
  25519. _onlyForInstancesIntermediate: boolean;
  25520. }
  25521. /**
  25522. * Class used to store all common mesh properties
  25523. */
  25524. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25525. /** No occlusion */
  25526. static OCCLUSION_TYPE_NONE: number;
  25527. /** Occlusion set to optimisitic */
  25528. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25529. /** Occlusion set to strict */
  25530. static OCCLUSION_TYPE_STRICT: number;
  25531. /** Use an accurante occlusion algorithm */
  25532. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25533. /** Use a conservative occlusion algorithm */
  25534. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25535. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25536. * Test order :
  25537. * Is the bounding sphere outside the frustum ?
  25538. * If not, are the bounding box vertices outside the frustum ?
  25539. * It not, then the cullable object is in the frustum.
  25540. */
  25541. static readonly CULLINGSTRATEGY_STANDARD: number;
  25542. /** Culling strategy : Bounding Sphere Only.
  25543. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25544. * It's also less accurate than the standard because some not visible objects can still be selected.
  25545. * Test : is the bounding sphere outside the frustum ?
  25546. * If not, then the cullable object is in the frustum.
  25547. */
  25548. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25549. /** Culling strategy : Optimistic Inclusion.
  25550. * This in an inclusion test first, then the standard exclusion test.
  25551. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25552. * 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.
  25553. * Anyway, it's as accurate as the standard strategy.
  25554. * Test :
  25555. * Is the cullable object bounding sphere center in the frustum ?
  25556. * If not, apply the default culling strategy.
  25557. */
  25558. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25559. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25560. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25561. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25562. * 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.
  25563. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25564. * Test :
  25565. * Is the cullable object bounding sphere center in the frustum ?
  25566. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25567. */
  25568. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25569. /**
  25570. * No billboard
  25571. */
  25572. static readonly BILLBOARDMODE_NONE: number;
  25573. /** Billboard on X axis */
  25574. static readonly BILLBOARDMODE_X: number;
  25575. /** Billboard on Y axis */
  25576. static readonly BILLBOARDMODE_Y: number;
  25577. /** Billboard on Z axis */
  25578. static readonly BILLBOARDMODE_Z: number;
  25579. /** Billboard on all axes */
  25580. static readonly BILLBOARDMODE_ALL: number;
  25581. /** @hidden */
  25582. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25583. /**
  25584. * The culling strategy to use to check whether the mesh must be rendered or not.
  25585. * This value can be changed at any time and will be used on the next render mesh selection.
  25586. * The possible values are :
  25587. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25588. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25589. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25590. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25591. * Please read each static variable documentation to get details about the culling process.
  25592. * */
  25593. cullingStrategy: number;
  25594. /**
  25595. * Gets the number of facets in the mesh
  25596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25597. */
  25598. readonly facetNb: number;
  25599. /**
  25600. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25602. */
  25603. partitioningSubdivisions: number;
  25604. /**
  25605. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25606. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25608. */
  25609. partitioningBBoxRatio: number;
  25610. /**
  25611. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25612. * Works only for updatable meshes.
  25613. * Doesn't work with multi-materials
  25614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25615. */
  25616. mustDepthSortFacets: boolean;
  25617. /**
  25618. * The location (Vector3) where the facet depth sort must be computed from.
  25619. * By default, the active camera position.
  25620. * Used only when facet depth sort is enabled
  25621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25622. */
  25623. facetDepthSortFrom: Vector3;
  25624. /**
  25625. * gets a boolean indicating if facetData is enabled
  25626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25627. */
  25628. readonly isFacetDataEnabled: boolean;
  25629. /** @hidden */
  25630. _updateNonUniformScalingState(value: boolean): boolean;
  25631. /**
  25632. * An event triggered when this mesh collides with another one
  25633. */
  25634. onCollideObservable: Observable<AbstractMesh>;
  25635. /** Set a function to call when this mesh collides with another one */
  25636. onCollide: () => void;
  25637. /**
  25638. * An event triggered when the collision's position changes
  25639. */
  25640. onCollisionPositionChangeObservable: Observable<Vector3>;
  25641. /** Set a function to call when the collision's position changes */
  25642. onCollisionPositionChange: () => void;
  25643. /**
  25644. * An event triggered when material is changed
  25645. */
  25646. onMaterialChangedObservable: Observable<AbstractMesh>;
  25647. /**
  25648. * Gets or sets the orientation for POV movement & rotation
  25649. */
  25650. definedFacingForward: boolean;
  25651. /** @hidden */
  25652. _occlusionQuery: Nullable<WebGLQuery>;
  25653. /** @hidden */
  25654. _renderingGroup: Nullable<RenderingGroup>;
  25655. /**
  25656. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25657. */
  25658. /**
  25659. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25660. */
  25661. visibility: number;
  25662. /** Gets or sets the alpha index used to sort transparent meshes
  25663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25664. */
  25665. alphaIndex: number;
  25666. /**
  25667. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25668. */
  25669. isVisible: boolean;
  25670. /**
  25671. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25672. */
  25673. isPickable: boolean;
  25674. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25675. showSubMeshesBoundingBox: boolean;
  25676. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25678. */
  25679. isBlocker: boolean;
  25680. /**
  25681. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25682. */
  25683. enablePointerMoveEvents: boolean;
  25684. /**
  25685. * Specifies the rendering group id for this mesh (0 by default)
  25686. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25687. */
  25688. renderingGroupId: number;
  25689. private _material;
  25690. /** Gets or sets current material */
  25691. material: Nullable<Material>;
  25692. /**
  25693. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25694. * @see http://doc.babylonjs.com/babylon101/shadows
  25695. */
  25696. receiveShadows: boolean;
  25697. /** Defines color to use when rendering outline */
  25698. outlineColor: Color3;
  25699. /** Define width to use when rendering outline */
  25700. outlineWidth: number;
  25701. /** Defines color to use when rendering overlay */
  25702. overlayColor: Color3;
  25703. /** Defines alpha to use when rendering overlay */
  25704. overlayAlpha: number;
  25705. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25706. hasVertexAlpha: boolean;
  25707. /** 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) */
  25708. useVertexColors: boolean;
  25709. /**
  25710. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25711. */
  25712. computeBonesUsingShaders: boolean;
  25713. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25714. numBoneInfluencers: number;
  25715. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25716. applyFog: boolean;
  25717. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25718. useOctreeForRenderingSelection: boolean;
  25719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25720. useOctreeForPicking: boolean;
  25721. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25722. useOctreeForCollisions: boolean;
  25723. /**
  25724. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25725. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25726. */
  25727. layerMask: number;
  25728. /**
  25729. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25730. */
  25731. alwaysSelectAsActiveMesh: boolean;
  25732. /**
  25733. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25734. */
  25735. doNotSyncBoundingInfo: boolean;
  25736. /**
  25737. * Gets or sets the current action manager
  25738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25739. */
  25740. actionManager: Nullable<AbstractActionManager>;
  25741. private _meshCollisionData;
  25742. /**
  25743. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25745. */
  25746. ellipsoid: Vector3;
  25747. /**
  25748. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25750. */
  25751. ellipsoidOffset: Vector3;
  25752. /**
  25753. * Gets or sets a collision mask used to mask collisions (default is -1).
  25754. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25755. */
  25756. collisionMask: number;
  25757. /**
  25758. * Gets or sets the current collision group mask (-1 by default).
  25759. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25760. */
  25761. collisionGroup: number;
  25762. /**
  25763. * Defines edge width used when edgesRenderer is enabled
  25764. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25765. */
  25766. edgesWidth: number;
  25767. /**
  25768. * Defines edge color used when edgesRenderer is enabled
  25769. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25770. */
  25771. edgesColor: Color4;
  25772. /** @hidden */
  25773. _edgesRenderer: Nullable<IEdgesRenderer>;
  25774. /** @hidden */
  25775. _masterMesh: Nullable<AbstractMesh>;
  25776. /** @hidden */
  25777. _boundingInfo: Nullable<BoundingInfo>;
  25778. /** @hidden */
  25779. _renderId: number;
  25780. /**
  25781. * Gets or sets the list of subMeshes
  25782. * @see http://doc.babylonjs.com/how_to/multi_materials
  25783. */
  25784. subMeshes: SubMesh[];
  25785. /** @hidden */
  25786. _intersectionsInProgress: AbstractMesh[];
  25787. /** @hidden */
  25788. _unIndexed: boolean;
  25789. /** @hidden */
  25790. _lightSources: Light[];
  25791. /** Gets the list of lights affecting that mesh */
  25792. readonly lightSources: Light[];
  25793. /** @hidden */
  25794. readonly _positions: Nullable<Vector3[]>;
  25795. /** @hidden */
  25796. _waitingData: {
  25797. lods: Nullable<any>;
  25798. actions: Nullable<any>;
  25799. freezeWorldMatrix: Nullable<boolean>;
  25800. };
  25801. /** @hidden */
  25802. _bonesTransformMatrices: Nullable<Float32Array>;
  25803. /** @hidden */
  25804. _transformMatrixTexture: Nullable<RawTexture>;
  25805. /**
  25806. * Gets or sets a skeleton to apply skining transformations
  25807. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25808. */
  25809. skeleton: Nullable<Skeleton>;
  25810. /**
  25811. * An event triggered when the mesh is rebuilt.
  25812. */
  25813. onRebuildObservable: Observable<AbstractMesh>;
  25814. /**
  25815. * Creates a new AbstractMesh
  25816. * @param name defines the name of the mesh
  25817. * @param scene defines the hosting scene
  25818. */
  25819. constructor(name: string, scene?: Nullable<Scene>);
  25820. /**
  25821. * Returns the string "AbstractMesh"
  25822. * @returns "AbstractMesh"
  25823. */
  25824. getClassName(): string;
  25825. /**
  25826. * Gets a string representation of the current mesh
  25827. * @param fullDetails defines a boolean indicating if full details must be included
  25828. * @returns a string representation of the current mesh
  25829. */
  25830. toString(fullDetails?: boolean): string;
  25831. /**
  25832. * @hidden
  25833. */
  25834. protected _getEffectiveParent(): Nullable<Node>;
  25835. /** @hidden */
  25836. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25837. /** @hidden */
  25838. _rebuild(): void;
  25839. /** @hidden */
  25840. _resyncLightSources(): void;
  25841. /** @hidden */
  25842. _resyncLighSource(light: Light): void;
  25843. /** @hidden */
  25844. _unBindEffect(): void;
  25845. /** @hidden */
  25846. _removeLightSource(light: Light): void;
  25847. private _markSubMeshesAsDirty;
  25848. /** @hidden */
  25849. _markSubMeshesAsLightDirty(): void;
  25850. /** @hidden */
  25851. _markSubMeshesAsAttributesDirty(): void;
  25852. /** @hidden */
  25853. _markSubMeshesAsMiscDirty(): void;
  25854. /**
  25855. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25856. */
  25857. scaling: Vector3;
  25858. /**
  25859. * Returns true if the mesh is blocked. Implemented by child classes
  25860. */
  25861. readonly isBlocked: boolean;
  25862. /**
  25863. * Returns the mesh itself by default. Implemented by child classes
  25864. * @param camera defines the camera to use to pick the right LOD level
  25865. * @returns the currentAbstractMesh
  25866. */
  25867. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25868. /**
  25869. * Returns 0 by default. Implemented by child classes
  25870. * @returns an integer
  25871. */
  25872. getTotalVertices(): number;
  25873. /**
  25874. * Returns a positive integer : the total number of indices in this mesh geometry.
  25875. * @returns the numner of indices or zero if the mesh has no geometry.
  25876. */
  25877. getTotalIndices(): number;
  25878. /**
  25879. * Returns null by default. Implemented by child classes
  25880. * @returns null
  25881. */
  25882. getIndices(): Nullable<IndicesArray>;
  25883. /**
  25884. * Returns the array of the requested vertex data kind. Implemented by child classes
  25885. * @param kind defines the vertex data kind to use
  25886. * @returns null
  25887. */
  25888. getVerticesData(kind: string): Nullable<FloatArray>;
  25889. /**
  25890. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25891. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25892. * Note that a new underlying VertexBuffer object is created each call.
  25893. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25894. * @param kind defines vertex data kind:
  25895. * * VertexBuffer.PositionKind
  25896. * * VertexBuffer.UVKind
  25897. * * VertexBuffer.UV2Kind
  25898. * * VertexBuffer.UV3Kind
  25899. * * VertexBuffer.UV4Kind
  25900. * * VertexBuffer.UV5Kind
  25901. * * VertexBuffer.UV6Kind
  25902. * * VertexBuffer.ColorKind
  25903. * * VertexBuffer.MatricesIndicesKind
  25904. * * VertexBuffer.MatricesIndicesExtraKind
  25905. * * VertexBuffer.MatricesWeightsKind
  25906. * * VertexBuffer.MatricesWeightsExtraKind
  25907. * @param data defines the data source
  25908. * @param updatable defines if the data must be flagged as updatable (or static)
  25909. * @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
  25910. * @returns the current mesh
  25911. */
  25912. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25913. /**
  25914. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25915. * If the mesh has no geometry, it is simply returned as it is.
  25916. * @param kind defines vertex data kind:
  25917. * * VertexBuffer.PositionKind
  25918. * * VertexBuffer.UVKind
  25919. * * VertexBuffer.UV2Kind
  25920. * * VertexBuffer.UV3Kind
  25921. * * VertexBuffer.UV4Kind
  25922. * * VertexBuffer.UV5Kind
  25923. * * VertexBuffer.UV6Kind
  25924. * * VertexBuffer.ColorKind
  25925. * * VertexBuffer.MatricesIndicesKind
  25926. * * VertexBuffer.MatricesIndicesExtraKind
  25927. * * VertexBuffer.MatricesWeightsKind
  25928. * * VertexBuffer.MatricesWeightsExtraKind
  25929. * @param data defines the data source
  25930. * @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
  25931. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25932. * @returns the current mesh
  25933. */
  25934. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25935. /**
  25936. * Sets the mesh indices,
  25937. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25938. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25939. * @param totalVertices Defines the total number of vertices
  25940. * @returns the current mesh
  25941. */
  25942. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25943. /**
  25944. * Gets a boolean indicating if specific vertex data is present
  25945. * @param kind defines the vertex data kind to use
  25946. * @returns true is data kind is present
  25947. */
  25948. isVerticesDataPresent(kind: string): boolean;
  25949. /**
  25950. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25951. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25952. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25953. * @returns a BoundingInfo
  25954. */
  25955. getBoundingInfo(): BoundingInfo;
  25956. /**
  25957. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25958. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25959. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25960. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25961. * @returns the current mesh
  25962. */
  25963. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25964. /**
  25965. * Overwrite the current bounding info
  25966. * @param boundingInfo defines the new bounding info
  25967. * @returns the current mesh
  25968. */
  25969. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25970. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25971. readonly useBones: boolean;
  25972. /** @hidden */
  25973. _preActivate(): void;
  25974. /** @hidden */
  25975. _preActivateForIntermediateRendering(renderId: number): void;
  25976. /** @hidden */
  25977. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25978. /** @hidden */
  25979. _postActivate(): void;
  25980. /** @hidden */
  25981. _freeze(): void;
  25982. /** @hidden */
  25983. _unFreeze(): void;
  25984. /**
  25985. * Gets the current world matrix
  25986. * @returns a Matrix
  25987. */
  25988. getWorldMatrix(): Matrix;
  25989. /** @hidden */
  25990. _getWorldMatrixDeterminant(): number;
  25991. /**
  25992. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25993. */
  25994. readonly isAnInstance: boolean;
  25995. /**
  25996. * Perform relative position change from the point of view of behind the front of the mesh.
  25997. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25998. * Supports definition of mesh facing forward or backward
  25999. * @param amountRight defines the distance on the right axis
  26000. * @param amountUp defines the distance on the up axis
  26001. * @param amountForward defines the distance on the forward axis
  26002. * @returns the current mesh
  26003. */
  26004. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26005. /**
  26006. * Calculate relative position change from the point of view of behind the front of the mesh.
  26007. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26008. * Supports definition of mesh facing forward or backward
  26009. * @param amountRight defines the distance on the right axis
  26010. * @param amountUp defines the distance on the up axis
  26011. * @param amountForward defines the distance on the forward axis
  26012. * @returns the new displacement vector
  26013. */
  26014. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26015. /**
  26016. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26017. * Supports definition of mesh facing forward or backward
  26018. * @param flipBack defines the flip
  26019. * @param twirlClockwise defines the twirl
  26020. * @param tiltRight defines the tilt
  26021. * @returns the current mesh
  26022. */
  26023. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26024. /**
  26025. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26026. * Supports definition of mesh facing forward or backward.
  26027. * @param flipBack defines the flip
  26028. * @param twirlClockwise defines the twirl
  26029. * @param tiltRight defines the tilt
  26030. * @returns the new rotation vector
  26031. */
  26032. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26033. /**
  26034. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26035. * This means the mesh underlying bounding box and sphere are recomputed.
  26036. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26037. * @returns the current mesh
  26038. */
  26039. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26040. /** @hidden */
  26041. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26042. /** @hidden */
  26043. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26044. /** @hidden */
  26045. _updateBoundingInfo(): AbstractMesh;
  26046. /** @hidden */
  26047. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26048. /** @hidden */
  26049. protected _afterComputeWorldMatrix(): void;
  26050. /** @hidden */
  26051. readonly _effectiveMesh: AbstractMesh;
  26052. /**
  26053. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26054. * A mesh is in the frustum if its bounding box intersects the frustum
  26055. * @param frustumPlanes defines the frustum to test
  26056. * @returns true if the mesh is in the frustum planes
  26057. */
  26058. isInFrustum(frustumPlanes: Plane[]): boolean;
  26059. /**
  26060. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26061. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26062. * @param frustumPlanes defines the frustum to test
  26063. * @returns true if the mesh is completely in the frustum planes
  26064. */
  26065. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26066. /**
  26067. * True if the mesh intersects another mesh or a SolidParticle object
  26068. * @param mesh defines a target mesh or SolidParticle to test
  26069. * @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)
  26070. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26071. * @returns true if there is an intersection
  26072. */
  26073. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26074. /**
  26075. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26076. * @param point defines the point to test
  26077. * @returns true if there is an intersection
  26078. */
  26079. intersectsPoint(point: Vector3): boolean;
  26080. /**
  26081. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26083. */
  26084. checkCollisions: boolean;
  26085. /**
  26086. * Gets Collider object used to compute collisions (not physics)
  26087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26088. */
  26089. readonly collider: Nullable<Collider>;
  26090. /**
  26091. * Move the mesh using collision engine
  26092. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26093. * @param displacement defines the requested displacement vector
  26094. * @returns the current mesh
  26095. */
  26096. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26097. private _onCollisionPositionChange;
  26098. /** @hidden */
  26099. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26100. /** @hidden */
  26101. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26102. /** @hidden */
  26103. _checkCollision(collider: Collider): AbstractMesh;
  26104. /** @hidden */
  26105. _generatePointsArray(): boolean;
  26106. /**
  26107. * Checks if the passed Ray intersects with the mesh
  26108. * @param ray defines the ray to use
  26109. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26111. * @returns the picking info
  26112. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26113. */
  26114. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26115. /**
  26116. * Clones the current mesh
  26117. * @param name defines the mesh name
  26118. * @param newParent defines the new mesh parent
  26119. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26120. * @returns the new mesh
  26121. */
  26122. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26123. /**
  26124. * Disposes all the submeshes of the current meshnp
  26125. * @returns the current mesh
  26126. */
  26127. releaseSubMeshes(): AbstractMesh;
  26128. /**
  26129. * Releases resources associated with this abstract mesh.
  26130. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26131. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26132. */
  26133. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26134. /**
  26135. * Adds the passed mesh as a child to the current mesh
  26136. * @param mesh defines the child mesh
  26137. * @returns the current mesh
  26138. */
  26139. addChild(mesh: AbstractMesh): AbstractMesh;
  26140. /**
  26141. * Removes the passed mesh from the current mesh children list
  26142. * @param mesh defines the child mesh
  26143. * @returns the current mesh
  26144. */
  26145. removeChild(mesh: AbstractMesh): AbstractMesh;
  26146. /** @hidden */
  26147. private _initFacetData;
  26148. /**
  26149. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26150. * This method can be called within the render loop.
  26151. * 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
  26152. * @returns the current mesh
  26153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26154. */
  26155. updateFacetData(): AbstractMesh;
  26156. /**
  26157. * Returns the facetLocalNormals array.
  26158. * The normals are expressed in the mesh local spac
  26159. * @returns an array of Vector3
  26160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26161. */
  26162. getFacetLocalNormals(): Vector3[];
  26163. /**
  26164. * Returns the facetLocalPositions array.
  26165. * The facet positions are expressed in the mesh local space
  26166. * @returns an array of Vector3
  26167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26168. */
  26169. getFacetLocalPositions(): Vector3[];
  26170. /**
  26171. * Returns the facetLocalPartioning array
  26172. * @returns an array of array of numbers
  26173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26174. */
  26175. getFacetLocalPartitioning(): number[][];
  26176. /**
  26177. * Returns the i-th facet position in the world system.
  26178. * This method allocates a new Vector3 per call
  26179. * @param i defines the facet index
  26180. * @returns a new Vector3
  26181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26182. */
  26183. getFacetPosition(i: number): Vector3;
  26184. /**
  26185. * Sets the reference Vector3 with the i-th facet position in the world system
  26186. * @param i defines the facet index
  26187. * @param ref defines the target vector
  26188. * @returns the current mesh
  26189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26190. */
  26191. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26192. /**
  26193. * Returns the i-th facet normal in the world system.
  26194. * This method allocates a new Vector3 per call
  26195. * @param i defines the facet index
  26196. * @returns a new Vector3
  26197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26198. */
  26199. getFacetNormal(i: number): Vector3;
  26200. /**
  26201. * Sets the reference Vector3 with the i-th facet normal in the world system
  26202. * @param i defines the facet index
  26203. * @param ref defines the target vector
  26204. * @returns the current mesh
  26205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26206. */
  26207. getFacetNormalToRef(i: number, ref: Vector3): this;
  26208. /**
  26209. * 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)
  26210. * @param x defines x coordinate
  26211. * @param y defines y coordinate
  26212. * @param z defines z coordinate
  26213. * @returns the array of facet indexes
  26214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26215. */
  26216. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26217. /**
  26218. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26219. * @param projected sets as the (x,y,z) world projection on the facet
  26220. * @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
  26221. * @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
  26222. * @param x defines x coordinate
  26223. * @param y defines y coordinate
  26224. * @param z defines z coordinate
  26225. * @returns the face index if found (or null instead)
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26227. */
  26228. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26229. /**
  26230. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26231. * @param projected sets as the (x,y,z) local projection on the facet
  26232. * @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
  26233. * @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
  26234. * @param x defines x coordinate
  26235. * @param y defines y coordinate
  26236. * @param z defines z coordinate
  26237. * @returns the face index if found (or null instead)
  26238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26239. */
  26240. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26241. /**
  26242. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26243. * @returns the parameters
  26244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26245. */
  26246. getFacetDataParameters(): any;
  26247. /**
  26248. * Disables the feature FacetData and frees the related memory
  26249. * @returns the current mesh
  26250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26251. */
  26252. disableFacetData(): AbstractMesh;
  26253. /**
  26254. * Updates the AbstractMesh indices array
  26255. * @param indices defines the data source
  26256. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26257. * @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)
  26258. * @returns the current mesh
  26259. */
  26260. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26261. /**
  26262. * Creates new normals data for the mesh
  26263. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26264. * @returns the current mesh
  26265. */
  26266. createNormals(updatable: boolean): AbstractMesh;
  26267. /**
  26268. * Align the mesh with a normal
  26269. * @param normal defines the normal to use
  26270. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26271. * @returns the current mesh
  26272. */
  26273. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26274. /** @hidden */
  26275. _checkOcclusionQuery(): boolean;
  26276. /**
  26277. * Disables the mesh edge rendering mode
  26278. * @returns the currentAbstractMesh
  26279. */
  26280. disableEdgesRendering(): AbstractMesh;
  26281. /**
  26282. * Enables the edge rendering mode on the mesh.
  26283. * This mode makes the mesh edges visible
  26284. * @param epsilon defines the maximal distance between two angles to detect a face
  26285. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26286. * @returns the currentAbstractMesh
  26287. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26288. */
  26289. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26290. }
  26291. }
  26292. declare module BABYLON {
  26293. /**
  26294. * Interface used to define ActionEvent
  26295. */
  26296. export interface IActionEvent {
  26297. /** The mesh or sprite that triggered the action */
  26298. source: any;
  26299. /** The X mouse cursor position at the time of the event */
  26300. pointerX: number;
  26301. /** The Y mouse cursor position at the time of the event */
  26302. pointerY: number;
  26303. /** The mesh that is currently pointed at (can be null) */
  26304. meshUnderPointer: Nullable<AbstractMesh>;
  26305. /** the original (browser) event that triggered the ActionEvent */
  26306. sourceEvent?: any;
  26307. /** additional data for the event */
  26308. additionalData?: any;
  26309. }
  26310. /**
  26311. * ActionEvent is the event being sent when an action is triggered.
  26312. */
  26313. export class ActionEvent implements IActionEvent {
  26314. /** The mesh or sprite that triggered the action */
  26315. source: any;
  26316. /** The X mouse cursor position at the time of the event */
  26317. pointerX: number;
  26318. /** The Y mouse cursor position at the time of the event */
  26319. pointerY: number;
  26320. /** The mesh that is currently pointed at (can be null) */
  26321. meshUnderPointer: Nullable<AbstractMesh>;
  26322. /** the original (browser) event that triggered the ActionEvent */
  26323. sourceEvent?: any;
  26324. /** additional data for the event */
  26325. additionalData?: any;
  26326. /**
  26327. * Creates a new ActionEvent
  26328. * @param source The mesh or sprite that triggered the action
  26329. * @param pointerX The X mouse cursor position at the time of the event
  26330. * @param pointerY The Y mouse cursor position at the time of the event
  26331. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26332. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26333. * @param additionalData additional data for the event
  26334. */
  26335. constructor(
  26336. /** The mesh or sprite that triggered the action */
  26337. source: any,
  26338. /** The X mouse cursor position at the time of the event */
  26339. pointerX: number,
  26340. /** The Y mouse cursor position at the time of the event */
  26341. pointerY: number,
  26342. /** The mesh that is currently pointed at (can be null) */
  26343. meshUnderPointer: Nullable<AbstractMesh>,
  26344. /** the original (browser) event that triggered the ActionEvent */
  26345. sourceEvent?: any,
  26346. /** additional data for the event */
  26347. additionalData?: any);
  26348. /**
  26349. * Helper function to auto-create an ActionEvent from a source mesh.
  26350. * @param source The source mesh that triggered the event
  26351. * @param evt The original (browser) event
  26352. * @param additionalData additional data for the event
  26353. * @returns the new ActionEvent
  26354. */
  26355. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26356. /**
  26357. * Helper function to auto-create an ActionEvent from a source sprite
  26358. * @param source The source sprite that triggered the event
  26359. * @param scene Scene associated with the sprite
  26360. * @param evt The original (browser) event
  26361. * @param additionalData additional data for the event
  26362. * @returns the new ActionEvent
  26363. */
  26364. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26365. /**
  26366. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26367. * @param scene the scene where the event occurred
  26368. * @param evt The original (browser) event
  26369. * @returns the new ActionEvent
  26370. */
  26371. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26372. /**
  26373. * Helper function to auto-create an ActionEvent from a primitive
  26374. * @param prim defines the target primitive
  26375. * @param pointerPos defines the pointer position
  26376. * @param evt The original (browser) event
  26377. * @param additionalData additional data for the event
  26378. * @returns the new ActionEvent
  26379. */
  26380. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26381. }
  26382. }
  26383. declare module BABYLON {
  26384. /**
  26385. * Abstract class used to decouple action Manager from scene and meshes.
  26386. * Do not instantiate.
  26387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26388. */
  26389. export abstract class AbstractActionManager implements IDisposable {
  26390. /** Gets the list of active triggers */
  26391. static Triggers: {
  26392. [key: string]: number;
  26393. };
  26394. /** Gets the cursor to use when hovering items */
  26395. hoverCursor: string;
  26396. /** Gets the list of actions */
  26397. actions: IAction[];
  26398. /**
  26399. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26400. */
  26401. isRecursive: boolean;
  26402. /**
  26403. * Releases all associated resources
  26404. */
  26405. abstract dispose(): void;
  26406. /**
  26407. * Does this action manager has pointer triggers
  26408. */
  26409. abstract readonly hasPointerTriggers: boolean;
  26410. /**
  26411. * Does this action manager has pick triggers
  26412. */
  26413. abstract readonly hasPickTriggers: boolean;
  26414. /**
  26415. * Process a specific trigger
  26416. * @param trigger defines the trigger to process
  26417. * @param evt defines the event details to be processed
  26418. */
  26419. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26420. /**
  26421. * Does this action manager handles actions of any of the given triggers
  26422. * @param triggers defines the triggers to be tested
  26423. * @return a boolean indicating whether one (or more) of the triggers is handled
  26424. */
  26425. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26426. /**
  26427. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26428. * speed.
  26429. * @param triggerA defines the trigger to be tested
  26430. * @param triggerB defines the trigger to be tested
  26431. * @return a boolean indicating whether one (or more) of the triggers is handled
  26432. */
  26433. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26434. /**
  26435. * Does this action manager handles actions of a given trigger
  26436. * @param trigger defines the trigger to be tested
  26437. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26438. * @return whether the trigger is handled
  26439. */
  26440. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26441. /**
  26442. * Serialize this manager to a JSON object
  26443. * @param name defines the property name to store this manager
  26444. * @returns a JSON representation of this manager
  26445. */
  26446. abstract serialize(name: string): any;
  26447. /**
  26448. * Registers an action to this action manager
  26449. * @param action defines the action to be registered
  26450. * @return the action amended (prepared) after registration
  26451. */
  26452. abstract registerAction(action: IAction): Nullable<IAction>;
  26453. /**
  26454. * Unregisters an action to this action manager
  26455. * @param action defines the action to be unregistered
  26456. * @return a boolean indicating whether the action has been unregistered
  26457. */
  26458. abstract unregisterAction(action: IAction): Boolean;
  26459. /**
  26460. * Does exist one action manager with at least one trigger
  26461. **/
  26462. static readonly HasTriggers: boolean;
  26463. /**
  26464. * Does exist one action manager with at least one pick trigger
  26465. **/
  26466. static readonly HasPickTriggers: boolean;
  26467. /**
  26468. * Does exist one action manager that handles actions of a given trigger
  26469. * @param trigger defines the trigger to be tested
  26470. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26471. **/
  26472. static HasSpecificTrigger(trigger: number): boolean;
  26473. }
  26474. }
  26475. declare module BABYLON {
  26476. /**
  26477. * Defines how a node can be built from a string name.
  26478. */
  26479. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26480. /**
  26481. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26482. */
  26483. export class Node implements IBehaviorAware<Node> {
  26484. /** @hidden */
  26485. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26486. private static _NodeConstructors;
  26487. /**
  26488. * Add a new node constructor
  26489. * @param type defines the type name of the node to construct
  26490. * @param constructorFunc defines the constructor function
  26491. */
  26492. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26493. /**
  26494. * Returns a node constructor based on type name
  26495. * @param type defines the type name
  26496. * @param name defines the new node name
  26497. * @param scene defines the hosting scene
  26498. * @param options defines optional options to transmit to constructors
  26499. * @returns the new constructor or null
  26500. */
  26501. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26502. /**
  26503. * Gets or sets the name of the node
  26504. */
  26505. name: string;
  26506. /**
  26507. * Gets or sets the id of the node
  26508. */
  26509. id: string;
  26510. /**
  26511. * Gets or sets the unique id of the node
  26512. */
  26513. uniqueId: number;
  26514. /**
  26515. * Gets or sets a string used to store user defined state for the node
  26516. */
  26517. state: string;
  26518. /**
  26519. * Gets or sets an object used to store user defined information for the node
  26520. */
  26521. metadata: any;
  26522. /**
  26523. * For internal use only. Please do not use.
  26524. */
  26525. reservedDataStore: any;
  26526. /**
  26527. * List of inspectable custom properties (used by the Inspector)
  26528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26529. */
  26530. inspectableCustomProperties: IInspectable[];
  26531. /**
  26532. * Gets or sets a boolean used to define if the node must be serialized
  26533. */
  26534. doNotSerialize: boolean;
  26535. /** @hidden */
  26536. _isDisposed: boolean;
  26537. /**
  26538. * Gets a list of Animations associated with the node
  26539. */
  26540. animations: Animation[];
  26541. protected _ranges: {
  26542. [name: string]: Nullable<AnimationRange>;
  26543. };
  26544. /**
  26545. * Callback raised when the node is ready to be used
  26546. */
  26547. onReady: Nullable<(node: Node) => void>;
  26548. private _isEnabled;
  26549. private _isParentEnabled;
  26550. private _isReady;
  26551. /** @hidden */
  26552. _currentRenderId: number;
  26553. private _parentUpdateId;
  26554. /** @hidden */
  26555. _childUpdateId: number;
  26556. /** @hidden */
  26557. _waitingParentId: Nullable<string>;
  26558. /** @hidden */
  26559. _scene: Scene;
  26560. /** @hidden */
  26561. _cache: any;
  26562. private _parentNode;
  26563. private _children;
  26564. /** @hidden */
  26565. _worldMatrix: Matrix;
  26566. /** @hidden */
  26567. _worldMatrixDeterminant: number;
  26568. /** @hidden */
  26569. _worldMatrixDeterminantIsDirty: boolean;
  26570. /** @hidden */
  26571. private _sceneRootNodesIndex;
  26572. /**
  26573. * Gets a boolean indicating if the node has been disposed
  26574. * @returns true if the node was disposed
  26575. */
  26576. isDisposed(): boolean;
  26577. /**
  26578. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26579. * @see https://doc.babylonjs.com/how_to/parenting
  26580. */
  26581. parent: Nullable<Node>;
  26582. private addToSceneRootNodes;
  26583. private removeFromSceneRootNodes;
  26584. private _animationPropertiesOverride;
  26585. /**
  26586. * Gets or sets the animation properties override
  26587. */
  26588. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26589. /**
  26590. * Gets a string idenfifying the name of the class
  26591. * @returns "Node" string
  26592. */
  26593. getClassName(): string;
  26594. /** @hidden */
  26595. readonly _isNode: boolean;
  26596. /**
  26597. * An event triggered when the mesh is disposed
  26598. */
  26599. onDisposeObservable: Observable<Node>;
  26600. private _onDisposeObserver;
  26601. /**
  26602. * Sets a callback that will be raised when the node will be disposed
  26603. */
  26604. onDispose: () => void;
  26605. /**
  26606. * Creates a new Node
  26607. * @param name the name and id to be given to this node
  26608. * @param scene the scene this node will be added to
  26609. * @param addToRootNodes the node will be added to scene.rootNodes
  26610. */
  26611. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26612. /**
  26613. * Gets the scene of the node
  26614. * @returns a scene
  26615. */
  26616. getScene(): Scene;
  26617. /**
  26618. * Gets the engine of the node
  26619. * @returns a Engine
  26620. */
  26621. getEngine(): Engine;
  26622. private _behaviors;
  26623. /**
  26624. * Attach a behavior to the node
  26625. * @see http://doc.babylonjs.com/features/behaviour
  26626. * @param behavior defines the behavior to attach
  26627. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26628. * @returns the current Node
  26629. */
  26630. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26631. /**
  26632. * Remove an attached behavior
  26633. * @see http://doc.babylonjs.com/features/behaviour
  26634. * @param behavior defines the behavior to attach
  26635. * @returns the current Node
  26636. */
  26637. removeBehavior(behavior: Behavior<Node>): Node;
  26638. /**
  26639. * Gets the list of attached behaviors
  26640. * @see http://doc.babylonjs.com/features/behaviour
  26641. */
  26642. readonly behaviors: Behavior<Node>[];
  26643. /**
  26644. * Gets an attached behavior by name
  26645. * @param name defines the name of the behavior to look for
  26646. * @see http://doc.babylonjs.com/features/behaviour
  26647. * @returns null if behavior was not found else the requested behavior
  26648. */
  26649. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26650. /**
  26651. * Returns the latest update of the World matrix
  26652. * @returns a Matrix
  26653. */
  26654. getWorldMatrix(): Matrix;
  26655. /** @hidden */
  26656. _getWorldMatrixDeterminant(): number;
  26657. /**
  26658. * Returns directly the latest state of the mesh World matrix.
  26659. * A Matrix is returned.
  26660. */
  26661. readonly worldMatrixFromCache: Matrix;
  26662. /** @hidden */
  26663. _initCache(): void;
  26664. /** @hidden */
  26665. updateCache(force?: boolean): void;
  26666. /** @hidden */
  26667. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26668. /** @hidden */
  26669. _updateCache(ignoreParentClass?: boolean): void;
  26670. /** @hidden */
  26671. _isSynchronized(): boolean;
  26672. /** @hidden */
  26673. _markSyncedWithParent(): void;
  26674. /** @hidden */
  26675. isSynchronizedWithParent(): boolean;
  26676. /** @hidden */
  26677. isSynchronized(): boolean;
  26678. /**
  26679. * Is this node ready to be used/rendered
  26680. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26681. * @return true if the node is ready
  26682. */
  26683. isReady(completeCheck?: boolean): boolean;
  26684. /**
  26685. * Is this node enabled?
  26686. * 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
  26687. * @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
  26688. * @return whether this node (and its parent) is enabled
  26689. */
  26690. isEnabled(checkAncestors?: boolean): boolean;
  26691. /** @hidden */
  26692. protected _syncParentEnabledState(): void;
  26693. /**
  26694. * Set the enabled state of this node
  26695. * @param value defines the new enabled state
  26696. */
  26697. setEnabled(value: boolean): void;
  26698. /**
  26699. * Is this node a descendant of the given node?
  26700. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26701. * @param ancestor defines the parent node to inspect
  26702. * @returns a boolean indicating if this node is a descendant of the given node
  26703. */
  26704. isDescendantOf(ancestor: Node): boolean;
  26705. /** @hidden */
  26706. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26707. /**
  26708. * Will return all nodes that have this node as ascendant
  26709. * @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
  26710. * @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
  26711. * @return all children nodes of all types
  26712. */
  26713. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26714. /**
  26715. * Get all child-meshes of this node
  26716. * @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)
  26717. * @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
  26718. * @returns an array of AbstractMesh
  26719. */
  26720. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26721. /**
  26722. * Get all direct children of this node
  26723. * @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
  26724. * @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)
  26725. * @returns an array of Node
  26726. */
  26727. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26728. /** @hidden */
  26729. _setReady(state: boolean): void;
  26730. /**
  26731. * Get an animation by name
  26732. * @param name defines the name of the animation to look for
  26733. * @returns null if not found else the requested animation
  26734. */
  26735. getAnimationByName(name: string): Nullable<Animation>;
  26736. /**
  26737. * Creates an animation range for this node
  26738. * @param name defines the name of the range
  26739. * @param from defines the starting key
  26740. * @param to defines the end key
  26741. */
  26742. createAnimationRange(name: string, from: number, to: number): void;
  26743. /**
  26744. * Delete a specific animation range
  26745. * @param name defines the name of the range to delete
  26746. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26747. */
  26748. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26749. /**
  26750. * Get an animation range by name
  26751. * @param name defines the name of the animation range to look for
  26752. * @returns null if not found else the requested animation range
  26753. */
  26754. getAnimationRange(name: string): Nullable<AnimationRange>;
  26755. /**
  26756. * Gets the list of all animation ranges defined on this node
  26757. * @returns an array
  26758. */
  26759. getAnimationRanges(): Nullable<AnimationRange>[];
  26760. /**
  26761. * Will start the animation sequence
  26762. * @param name defines the range frames for animation sequence
  26763. * @param loop defines if the animation should loop (false by default)
  26764. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26765. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26766. * @returns the object created for this animation. If range does not exist, it will return null
  26767. */
  26768. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26769. /**
  26770. * Serialize animation ranges into a JSON compatible object
  26771. * @returns serialization object
  26772. */
  26773. serializeAnimationRanges(): any;
  26774. /**
  26775. * Computes the world matrix of the node
  26776. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26777. * @returns the world matrix
  26778. */
  26779. computeWorldMatrix(force?: boolean): Matrix;
  26780. /**
  26781. * Releases resources associated with this node.
  26782. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26783. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26784. */
  26785. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26786. /**
  26787. * Parse animation range data from a serialization object and store them into a given node
  26788. * @param node defines where to store the animation ranges
  26789. * @param parsedNode defines the serialization object to read data from
  26790. * @param scene defines the hosting scene
  26791. */
  26792. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26793. /**
  26794. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26795. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26796. * @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
  26797. * @returns the new bounding vectors
  26798. */
  26799. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26800. min: Vector3;
  26801. max: Vector3;
  26802. };
  26803. }
  26804. }
  26805. declare module BABYLON {
  26806. /**
  26807. * @hidden
  26808. */
  26809. export class _IAnimationState {
  26810. key: number;
  26811. repeatCount: number;
  26812. workValue?: any;
  26813. loopMode?: number;
  26814. offsetValue?: any;
  26815. highLimitValue?: any;
  26816. }
  26817. /**
  26818. * Class used to store any kind of animation
  26819. */
  26820. export class Animation {
  26821. /**Name of the animation */
  26822. name: string;
  26823. /**Property to animate */
  26824. targetProperty: string;
  26825. /**The frames per second of the animation */
  26826. framePerSecond: number;
  26827. /**The data type of the animation */
  26828. dataType: number;
  26829. /**The loop mode of the animation */
  26830. loopMode?: number | undefined;
  26831. /**Specifies if blending should be enabled */
  26832. enableBlending?: boolean | undefined;
  26833. /**
  26834. * Use matrix interpolation instead of using direct key value when animating matrices
  26835. */
  26836. static AllowMatricesInterpolation: boolean;
  26837. /**
  26838. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26839. */
  26840. static AllowMatrixDecomposeForInterpolation: boolean;
  26841. /**
  26842. * Stores the key frames of the animation
  26843. */
  26844. private _keys;
  26845. /**
  26846. * Stores the easing function of the animation
  26847. */
  26848. private _easingFunction;
  26849. /**
  26850. * @hidden Internal use only
  26851. */
  26852. _runtimeAnimations: RuntimeAnimation[];
  26853. /**
  26854. * The set of event that will be linked to this animation
  26855. */
  26856. private _events;
  26857. /**
  26858. * Stores an array of target property paths
  26859. */
  26860. targetPropertyPath: string[];
  26861. /**
  26862. * Stores the blending speed of the animation
  26863. */
  26864. blendingSpeed: number;
  26865. /**
  26866. * Stores the animation ranges for the animation
  26867. */
  26868. private _ranges;
  26869. /**
  26870. * @hidden Internal use
  26871. */
  26872. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26873. /**
  26874. * Sets up an animation
  26875. * @param property The property to animate
  26876. * @param animationType The animation type to apply
  26877. * @param framePerSecond The frames per second of the animation
  26878. * @param easingFunction The easing function used in the animation
  26879. * @returns The created animation
  26880. */
  26881. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26882. /**
  26883. * Create and start an animation on a node
  26884. * @param name defines the name of the global animation that will be run on all nodes
  26885. * @param node defines the root node where the animation will take place
  26886. * @param targetProperty defines property to animate
  26887. * @param framePerSecond defines the number of frame per second yo use
  26888. * @param totalFrame defines the number of frames in total
  26889. * @param from defines the initial value
  26890. * @param to defines the final value
  26891. * @param loopMode defines which loop mode you want to use (off by default)
  26892. * @param easingFunction defines the easing function to use (linear by default)
  26893. * @param onAnimationEnd defines the callback to call when animation end
  26894. * @returns the animatable created for this animation
  26895. */
  26896. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26897. /**
  26898. * Create and start an animation on a node and its descendants
  26899. * @param name defines the name of the global animation that will be run on all nodes
  26900. * @param node defines the root node where the animation will take place
  26901. * @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
  26902. * @param targetProperty defines property to animate
  26903. * @param framePerSecond defines the number of frame per second to use
  26904. * @param totalFrame defines the number of frames in total
  26905. * @param from defines the initial value
  26906. * @param to defines the final value
  26907. * @param loopMode defines which loop mode you want to use (off by default)
  26908. * @param easingFunction defines the easing function to use (linear by default)
  26909. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26910. * @returns the list of animatables created for all nodes
  26911. * @example https://www.babylonjs-playground.com/#MH0VLI
  26912. */
  26913. 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[]>;
  26914. /**
  26915. * Creates a new animation, merges it with the existing animations and starts it
  26916. * @param name Name of the animation
  26917. * @param node Node which contains the scene that begins the animations
  26918. * @param targetProperty Specifies which property to animate
  26919. * @param framePerSecond The frames per second of the animation
  26920. * @param totalFrame The total number of frames
  26921. * @param from The frame at the beginning of the animation
  26922. * @param to The frame at the end of the animation
  26923. * @param loopMode Specifies the loop mode of the animation
  26924. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26925. * @param onAnimationEnd Callback to run once the animation is complete
  26926. * @returns Nullable animation
  26927. */
  26928. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26929. /**
  26930. * Transition property of an host to the target Value
  26931. * @param property The property to transition
  26932. * @param targetValue The target Value of the property
  26933. * @param host The object where the property to animate belongs
  26934. * @param scene Scene used to run the animation
  26935. * @param frameRate Framerate (in frame/s) to use
  26936. * @param transition The transition type we want to use
  26937. * @param duration The duration of the animation, in milliseconds
  26938. * @param onAnimationEnd Callback trigger at the end of the animation
  26939. * @returns Nullable animation
  26940. */
  26941. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26942. /**
  26943. * Return the array of runtime animations currently using this animation
  26944. */
  26945. readonly runtimeAnimations: RuntimeAnimation[];
  26946. /**
  26947. * Specifies if any of the runtime animations are currently running
  26948. */
  26949. readonly hasRunningRuntimeAnimations: boolean;
  26950. /**
  26951. * Initializes the animation
  26952. * @param name Name of the animation
  26953. * @param targetProperty Property to animate
  26954. * @param framePerSecond The frames per second of the animation
  26955. * @param dataType The data type of the animation
  26956. * @param loopMode The loop mode of the animation
  26957. * @param enableBlending Specifies if blending should be enabled
  26958. */
  26959. constructor(
  26960. /**Name of the animation */
  26961. name: string,
  26962. /**Property to animate */
  26963. targetProperty: string,
  26964. /**The frames per second of the animation */
  26965. framePerSecond: number,
  26966. /**The data type of the animation */
  26967. dataType: number,
  26968. /**The loop mode of the animation */
  26969. loopMode?: number | undefined,
  26970. /**Specifies if blending should be enabled */
  26971. enableBlending?: boolean | undefined);
  26972. /**
  26973. * Converts the animation to a string
  26974. * @param fullDetails support for multiple levels of logging within scene loading
  26975. * @returns String form of the animation
  26976. */
  26977. toString(fullDetails?: boolean): string;
  26978. /**
  26979. * Add an event to this animation
  26980. * @param event Event to add
  26981. */
  26982. addEvent(event: AnimationEvent): void;
  26983. /**
  26984. * Remove all events found at the given frame
  26985. * @param frame The frame to remove events from
  26986. */
  26987. removeEvents(frame: number): void;
  26988. /**
  26989. * Retrieves all the events from the animation
  26990. * @returns Events from the animation
  26991. */
  26992. getEvents(): AnimationEvent[];
  26993. /**
  26994. * Creates an animation range
  26995. * @param name Name of the animation range
  26996. * @param from Starting frame of the animation range
  26997. * @param to Ending frame of the animation
  26998. */
  26999. createRange(name: string, from: number, to: number): void;
  27000. /**
  27001. * Deletes an animation range by name
  27002. * @param name Name of the animation range to delete
  27003. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27004. */
  27005. deleteRange(name: string, deleteFrames?: boolean): void;
  27006. /**
  27007. * Gets the animation range by name, or null if not defined
  27008. * @param name Name of the animation range
  27009. * @returns Nullable animation range
  27010. */
  27011. getRange(name: string): Nullable<AnimationRange>;
  27012. /**
  27013. * Gets the key frames from the animation
  27014. * @returns The key frames of the animation
  27015. */
  27016. getKeys(): Array<IAnimationKey>;
  27017. /**
  27018. * Gets the highest frame rate of the animation
  27019. * @returns Highest frame rate of the animation
  27020. */
  27021. getHighestFrame(): number;
  27022. /**
  27023. * Gets the easing function of the animation
  27024. * @returns Easing function of the animation
  27025. */
  27026. getEasingFunction(): IEasingFunction;
  27027. /**
  27028. * Sets the easing function of the animation
  27029. * @param easingFunction A custom mathematical formula for animation
  27030. */
  27031. setEasingFunction(easingFunction: EasingFunction): void;
  27032. /**
  27033. * Interpolates a scalar linearly
  27034. * @param startValue Start value of the animation curve
  27035. * @param endValue End value of the animation curve
  27036. * @param gradient Scalar amount to interpolate
  27037. * @returns Interpolated scalar value
  27038. */
  27039. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27040. /**
  27041. * Interpolates a scalar cubically
  27042. * @param startValue Start value of the animation curve
  27043. * @param outTangent End tangent of the animation
  27044. * @param endValue End value of the animation curve
  27045. * @param inTangent Start tangent of the animation curve
  27046. * @param gradient Scalar amount to interpolate
  27047. * @returns Interpolated scalar value
  27048. */
  27049. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27050. /**
  27051. * Interpolates a quaternion using a spherical linear interpolation
  27052. * @param startValue Start value of the animation curve
  27053. * @param endValue End value of the animation curve
  27054. * @param gradient Scalar amount to interpolate
  27055. * @returns Interpolated quaternion value
  27056. */
  27057. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27058. /**
  27059. * Interpolates a quaternion cubically
  27060. * @param startValue Start value of the animation curve
  27061. * @param outTangent End tangent of the animation curve
  27062. * @param endValue End value of the animation curve
  27063. * @param inTangent Start tangent of the animation curve
  27064. * @param gradient Scalar amount to interpolate
  27065. * @returns Interpolated quaternion value
  27066. */
  27067. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27068. /**
  27069. * Interpolates a Vector3 linearl
  27070. * @param startValue Start value of the animation curve
  27071. * @param endValue End value of the animation curve
  27072. * @param gradient Scalar amount to interpolate
  27073. * @returns Interpolated scalar value
  27074. */
  27075. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27076. /**
  27077. * Interpolates a Vector3 cubically
  27078. * @param startValue Start value of the animation curve
  27079. * @param outTangent End tangent of the animation
  27080. * @param endValue End value of the animation curve
  27081. * @param inTangent Start tangent of the animation curve
  27082. * @param gradient Scalar amount to interpolate
  27083. * @returns InterpolatedVector3 value
  27084. */
  27085. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27086. /**
  27087. * Interpolates a Vector2 linearly
  27088. * @param startValue Start value of the animation curve
  27089. * @param endValue End value of the animation curve
  27090. * @param gradient Scalar amount to interpolate
  27091. * @returns Interpolated Vector2 value
  27092. */
  27093. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27094. /**
  27095. * Interpolates a Vector2 cubically
  27096. * @param startValue Start value of the animation curve
  27097. * @param outTangent End tangent of the animation
  27098. * @param endValue End value of the animation curve
  27099. * @param inTangent Start tangent of the animation curve
  27100. * @param gradient Scalar amount to interpolate
  27101. * @returns Interpolated Vector2 value
  27102. */
  27103. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27104. /**
  27105. * Interpolates a size linearly
  27106. * @param startValue Start value of the animation curve
  27107. * @param endValue End value of the animation curve
  27108. * @param gradient Scalar amount to interpolate
  27109. * @returns Interpolated Size value
  27110. */
  27111. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27112. /**
  27113. * Interpolates a Color3 linearly
  27114. * @param startValue Start value of the animation curve
  27115. * @param endValue End value of the animation curve
  27116. * @param gradient Scalar amount to interpolate
  27117. * @returns Interpolated Color3 value
  27118. */
  27119. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27120. /**
  27121. * @hidden Internal use only
  27122. */
  27123. _getKeyValue(value: any): any;
  27124. /**
  27125. * @hidden Internal use only
  27126. */
  27127. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27128. /**
  27129. * Defines the function to use to interpolate matrices
  27130. * @param startValue defines the start matrix
  27131. * @param endValue defines the end matrix
  27132. * @param gradient defines the gradient between both matrices
  27133. * @param result defines an optional target matrix where to store the interpolation
  27134. * @returns the interpolated matrix
  27135. */
  27136. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27137. /**
  27138. * Makes a copy of the animation
  27139. * @returns Cloned animation
  27140. */
  27141. clone(): Animation;
  27142. /**
  27143. * Sets the key frames of the animation
  27144. * @param values The animation key frames to set
  27145. */
  27146. setKeys(values: Array<IAnimationKey>): void;
  27147. /**
  27148. * Serializes the animation to an object
  27149. * @returns Serialized object
  27150. */
  27151. serialize(): any;
  27152. /**
  27153. * Float animation type
  27154. */
  27155. private static _ANIMATIONTYPE_FLOAT;
  27156. /**
  27157. * Vector3 animation type
  27158. */
  27159. private static _ANIMATIONTYPE_VECTOR3;
  27160. /**
  27161. * Quaternion animation type
  27162. */
  27163. private static _ANIMATIONTYPE_QUATERNION;
  27164. /**
  27165. * Matrix animation type
  27166. */
  27167. private static _ANIMATIONTYPE_MATRIX;
  27168. /**
  27169. * Color3 animation type
  27170. */
  27171. private static _ANIMATIONTYPE_COLOR3;
  27172. /**
  27173. * Vector2 animation type
  27174. */
  27175. private static _ANIMATIONTYPE_VECTOR2;
  27176. /**
  27177. * Size animation type
  27178. */
  27179. private static _ANIMATIONTYPE_SIZE;
  27180. /**
  27181. * Relative Loop Mode
  27182. */
  27183. private static _ANIMATIONLOOPMODE_RELATIVE;
  27184. /**
  27185. * Cycle Loop Mode
  27186. */
  27187. private static _ANIMATIONLOOPMODE_CYCLE;
  27188. /**
  27189. * Constant Loop Mode
  27190. */
  27191. private static _ANIMATIONLOOPMODE_CONSTANT;
  27192. /**
  27193. * Get the float animation type
  27194. */
  27195. static readonly ANIMATIONTYPE_FLOAT: number;
  27196. /**
  27197. * Get the Vector3 animation type
  27198. */
  27199. static readonly ANIMATIONTYPE_VECTOR3: number;
  27200. /**
  27201. * Get the Vector2 animation type
  27202. */
  27203. static readonly ANIMATIONTYPE_VECTOR2: number;
  27204. /**
  27205. * Get the Size animation type
  27206. */
  27207. static readonly ANIMATIONTYPE_SIZE: number;
  27208. /**
  27209. * Get the Quaternion animation type
  27210. */
  27211. static readonly ANIMATIONTYPE_QUATERNION: number;
  27212. /**
  27213. * Get the Matrix animation type
  27214. */
  27215. static readonly ANIMATIONTYPE_MATRIX: number;
  27216. /**
  27217. * Get the Color3 animation type
  27218. */
  27219. static readonly ANIMATIONTYPE_COLOR3: number;
  27220. /**
  27221. * Get the Relative Loop Mode
  27222. */
  27223. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27224. /**
  27225. * Get the Cycle Loop Mode
  27226. */
  27227. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27228. /**
  27229. * Get the Constant Loop Mode
  27230. */
  27231. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27232. /** @hidden */
  27233. static _UniversalLerp(left: any, right: any, amount: number): any;
  27234. /**
  27235. * Parses an animation object and creates an animation
  27236. * @param parsedAnimation Parsed animation object
  27237. * @returns Animation object
  27238. */
  27239. static Parse(parsedAnimation: any): Animation;
  27240. /**
  27241. * Appends the serialized animations from the source animations
  27242. * @param source Source containing the animations
  27243. * @param destination Target to store the animations
  27244. */
  27245. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27246. }
  27247. }
  27248. declare module BABYLON {
  27249. /**
  27250. * Interface containing an array of animations
  27251. */
  27252. export interface IAnimatable {
  27253. /**
  27254. * Array of animations
  27255. */
  27256. animations: Nullable<Array<Animation>>;
  27257. }
  27258. }
  27259. declare module BABYLON {
  27260. /**
  27261. * This represents all the required information to add a fresnel effect on a material:
  27262. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27263. */
  27264. export class FresnelParameters {
  27265. private _isEnabled;
  27266. /**
  27267. * Define if the fresnel effect is enable or not.
  27268. */
  27269. isEnabled: boolean;
  27270. /**
  27271. * Define the color used on edges (grazing angle)
  27272. */
  27273. leftColor: Color3;
  27274. /**
  27275. * Define the color used on center
  27276. */
  27277. rightColor: Color3;
  27278. /**
  27279. * Define bias applied to computed fresnel term
  27280. */
  27281. bias: number;
  27282. /**
  27283. * Defined the power exponent applied to fresnel term
  27284. */
  27285. power: number;
  27286. /**
  27287. * Clones the current fresnel and its valuues
  27288. * @returns a clone fresnel configuration
  27289. */
  27290. clone(): FresnelParameters;
  27291. /**
  27292. * Serializes the current fresnel parameters to a JSON representation.
  27293. * @return the JSON serialization
  27294. */
  27295. serialize(): any;
  27296. /**
  27297. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27298. * @param parsedFresnelParameters Define the JSON representation
  27299. * @returns the parsed parameters
  27300. */
  27301. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27302. }
  27303. }
  27304. declare module BABYLON {
  27305. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27306. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27307. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27308. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27309. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27310. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27311. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27312. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27313. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27314. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27315. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27316. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27317. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27318. /**
  27319. * Decorator used to define property that can be serialized as reference to a camera
  27320. * @param sourceName defines the name of the property to decorate
  27321. */
  27322. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27323. /**
  27324. * Class used to help serialization objects
  27325. */
  27326. export class SerializationHelper {
  27327. /** @hidden */
  27328. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27329. /** @hidden */
  27330. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27331. /** @hidden */
  27332. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27333. /** @hidden */
  27334. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27335. /**
  27336. * Appends the serialized animations from the source animations
  27337. * @param source Source containing the animations
  27338. * @param destination Target to store the animations
  27339. */
  27340. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27341. /**
  27342. * Static function used to serialized a specific entity
  27343. * @param entity defines the entity to serialize
  27344. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27345. * @returns a JSON compatible object representing the serialization of the entity
  27346. */
  27347. static Serialize<T>(entity: T, serializationObject?: any): any;
  27348. /**
  27349. * Creates a new entity from a serialization data object
  27350. * @param creationFunction defines a function used to instanciated the new entity
  27351. * @param source defines the source serialization data
  27352. * @param scene defines the hosting scene
  27353. * @param rootUrl defines the root url for resources
  27354. * @returns a new entity
  27355. */
  27356. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27357. /**
  27358. * Clones an object
  27359. * @param creationFunction defines the function used to instanciate the new object
  27360. * @param source defines the source object
  27361. * @returns the cloned object
  27362. */
  27363. static Clone<T>(creationFunction: () => T, source: T): T;
  27364. /**
  27365. * Instanciates a new object based on a source one (some data will be shared between both object)
  27366. * @param creationFunction defines the function used to instanciate the new object
  27367. * @param source defines the source object
  27368. * @returns the new object
  27369. */
  27370. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27371. }
  27372. }
  27373. declare module BABYLON {
  27374. /**
  27375. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27376. */
  27377. export interface CubeMapInfo {
  27378. /**
  27379. * The pixel array for the front face.
  27380. * This is stored in format, left to right, up to down format.
  27381. */
  27382. front: Nullable<ArrayBufferView>;
  27383. /**
  27384. * The pixel array for the back face.
  27385. * This is stored in format, left to right, up to down format.
  27386. */
  27387. back: Nullable<ArrayBufferView>;
  27388. /**
  27389. * The pixel array for the left face.
  27390. * This is stored in format, left to right, up to down format.
  27391. */
  27392. left: Nullable<ArrayBufferView>;
  27393. /**
  27394. * The pixel array for the right face.
  27395. * This is stored in format, left to right, up to down format.
  27396. */
  27397. right: Nullable<ArrayBufferView>;
  27398. /**
  27399. * The pixel array for the up face.
  27400. * This is stored in format, left to right, up to down format.
  27401. */
  27402. up: Nullable<ArrayBufferView>;
  27403. /**
  27404. * The pixel array for the down face.
  27405. * This is stored in format, left to right, up to down format.
  27406. */
  27407. down: Nullable<ArrayBufferView>;
  27408. /**
  27409. * The size of the cubemap stored.
  27410. *
  27411. * Each faces will be size * size pixels.
  27412. */
  27413. size: number;
  27414. /**
  27415. * The format of the texture.
  27416. *
  27417. * RGBA, RGB.
  27418. */
  27419. format: number;
  27420. /**
  27421. * The type of the texture data.
  27422. *
  27423. * UNSIGNED_INT, FLOAT.
  27424. */
  27425. type: number;
  27426. /**
  27427. * Specifies whether the texture is in gamma space.
  27428. */
  27429. gammaSpace: boolean;
  27430. }
  27431. /**
  27432. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27433. */
  27434. export class PanoramaToCubeMapTools {
  27435. private static FACE_FRONT;
  27436. private static FACE_BACK;
  27437. private static FACE_RIGHT;
  27438. private static FACE_LEFT;
  27439. private static FACE_DOWN;
  27440. private static FACE_UP;
  27441. /**
  27442. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27443. *
  27444. * @param float32Array The source data.
  27445. * @param inputWidth The width of the input panorama.
  27446. * @param inputHeight The height of the input panorama.
  27447. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27448. * @return The cubemap data
  27449. */
  27450. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27451. private static CreateCubemapTexture;
  27452. private static CalcProjectionSpherical;
  27453. }
  27454. }
  27455. declare module BABYLON {
  27456. /**
  27457. * Helper class dealing with the extraction of spherical polynomial dataArray
  27458. * from a cube map.
  27459. */
  27460. export class CubeMapToSphericalPolynomialTools {
  27461. private static FileFaces;
  27462. /**
  27463. * Converts a texture to the according Spherical Polynomial data.
  27464. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27465. *
  27466. * @param texture The texture to extract the information from.
  27467. * @return The Spherical Polynomial data.
  27468. */
  27469. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27470. /**
  27471. * Converts a cubemap to the according Spherical Polynomial data.
  27472. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27473. *
  27474. * @param cubeInfo The Cube map to extract the information from.
  27475. * @return The Spherical Polynomial data.
  27476. */
  27477. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27478. }
  27479. }
  27480. declare module BABYLON {
  27481. /**
  27482. * Class used to manipulate GUIDs
  27483. */
  27484. export class GUID {
  27485. /**
  27486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27487. * Be aware Math.random() could cause collisions, but:
  27488. * "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"
  27489. * @returns a pseudo random id
  27490. */
  27491. static RandomId(): string;
  27492. }
  27493. }
  27494. declare module BABYLON {
  27495. /**
  27496. * Base class of all the textures in babylon.
  27497. * It groups all the common properties the materials, post process, lights... might need
  27498. * in order to make a correct use of the texture.
  27499. */
  27500. export class BaseTexture implements IAnimatable {
  27501. /**
  27502. * Default anisotropic filtering level for the application.
  27503. * It is set to 4 as a good tradeoff between perf and quality.
  27504. */
  27505. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27506. /**
  27507. * Gets or sets the unique id of the texture
  27508. */
  27509. uniqueId: number;
  27510. /**
  27511. * Define the name of the texture.
  27512. */
  27513. name: string;
  27514. /**
  27515. * Gets or sets an object used to store user defined information.
  27516. */
  27517. metadata: any;
  27518. /**
  27519. * For internal use only. Please do not use.
  27520. */
  27521. reservedDataStore: any;
  27522. private _hasAlpha;
  27523. /**
  27524. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27525. */
  27526. hasAlpha: boolean;
  27527. /**
  27528. * Defines if the alpha value should be determined via the rgb values.
  27529. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27530. */
  27531. getAlphaFromRGB: boolean;
  27532. /**
  27533. * Intensity or strength of the texture.
  27534. * It is commonly used by materials to fine tune the intensity of the texture
  27535. */
  27536. level: number;
  27537. /**
  27538. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27539. * This is part of the texture as textures usually maps to one uv set.
  27540. */
  27541. coordinatesIndex: number;
  27542. private _coordinatesMode;
  27543. /**
  27544. * How a texture is mapped.
  27545. *
  27546. * | Value | Type | Description |
  27547. * | ----- | ----------------------------------- | ----------- |
  27548. * | 0 | EXPLICIT_MODE | |
  27549. * | 1 | SPHERICAL_MODE | |
  27550. * | 2 | PLANAR_MODE | |
  27551. * | 3 | CUBIC_MODE | |
  27552. * | 4 | PROJECTION_MODE | |
  27553. * | 5 | SKYBOX_MODE | |
  27554. * | 6 | INVCUBIC_MODE | |
  27555. * | 7 | EQUIRECTANGULAR_MODE | |
  27556. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27557. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27558. */
  27559. coordinatesMode: number;
  27560. /**
  27561. * | Value | Type | Description |
  27562. * | ----- | ------------------ | ----------- |
  27563. * | 0 | CLAMP_ADDRESSMODE | |
  27564. * | 1 | WRAP_ADDRESSMODE | |
  27565. * | 2 | MIRROR_ADDRESSMODE | |
  27566. */
  27567. wrapU: number;
  27568. /**
  27569. * | Value | Type | Description |
  27570. * | ----- | ------------------ | ----------- |
  27571. * | 0 | CLAMP_ADDRESSMODE | |
  27572. * | 1 | WRAP_ADDRESSMODE | |
  27573. * | 2 | MIRROR_ADDRESSMODE | |
  27574. */
  27575. wrapV: number;
  27576. /**
  27577. * | Value | Type | Description |
  27578. * | ----- | ------------------ | ----------- |
  27579. * | 0 | CLAMP_ADDRESSMODE | |
  27580. * | 1 | WRAP_ADDRESSMODE | |
  27581. * | 2 | MIRROR_ADDRESSMODE | |
  27582. */
  27583. wrapR: number;
  27584. /**
  27585. * With compliant hardware and browser (supporting anisotropic filtering)
  27586. * this defines the level of anisotropic filtering in the texture.
  27587. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27588. */
  27589. anisotropicFilteringLevel: number;
  27590. /**
  27591. * Define if the texture is a cube texture or if false a 2d texture.
  27592. */
  27593. isCube: boolean;
  27594. /**
  27595. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27596. */
  27597. is3D: boolean;
  27598. /**
  27599. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27600. * HDR texture are usually stored in linear space.
  27601. * This only impacts the PBR and Background materials
  27602. */
  27603. gammaSpace: boolean;
  27604. /**
  27605. * Gets whether or not the texture contains RGBD data.
  27606. */
  27607. readonly isRGBD: boolean;
  27608. /**
  27609. * Is Z inverted in the texture (useful in a cube texture).
  27610. */
  27611. invertZ: boolean;
  27612. /**
  27613. * Are mip maps generated for this texture or not.
  27614. */
  27615. readonly noMipmap: boolean;
  27616. /**
  27617. * @hidden
  27618. */
  27619. lodLevelInAlpha: boolean;
  27620. /**
  27621. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27622. */
  27623. lodGenerationOffset: number;
  27624. /**
  27625. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27626. */
  27627. lodGenerationScale: number;
  27628. /**
  27629. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27630. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27631. * average roughness values.
  27632. */
  27633. linearSpecularLOD: boolean;
  27634. /**
  27635. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27636. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27637. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27638. */
  27639. irradianceTexture: Nullable<BaseTexture>;
  27640. /**
  27641. * Define if the texture is a render target.
  27642. */
  27643. isRenderTarget: boolean;
  27644. /**
  27645. * Define the unique id of the texture in the scene.
  27646. */
  27647. readonly uid: string;
  27648. /**
  27649. * Return a string representation of the texture.
  27650. * @returns the texture as a string
  27651. */
  27652. toString(): string;
  27653. /**
  27654. * Get the class name of the texture.
  27655. * @returns "BaseTexture"
  27656. */
  27657. getClassName(): string;
  27658. /**
  27659. * Define the list of animation attached to the texture.
  27660. */
  27661. animations: Animation[];
  27662. /**
  27663. * An event triggered when the texture is disposed.
  27664. */
  27665. onDisposeObservable: Observable<BaseTexture>;
  27666. private _onDisposeObserver;
  27667. /**
  27668. * Callback triggered when the texture has been disposed.
  27669. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27670. */
  27671. onDispose: () => void;
  27672. /**
  27673. * Define the current state of the loading sequence when in delayed load mode.
  27674. */
  27675. delayLoadState: number;
  27676. private _scene;
  27677. /** @hidden */
  27678. _texture: Nullable<InternalTexture>;
  27679. private _uid;
  27680. /**
  27681. * Define if the texture is preventinga material to render or not.
  27682. * If not and the texture is not ready, the engine will use a default black texture instead.
  27683. */
  27684. readonly isBlocking: boolean;
  27685. /**
  27686. * Instantiates a new BaseTexture.
  27687. * Base class of all the textures in babylon.
  27688. * It groups all the common properties the materials, post process, lights... might need
  27689. * in order to make a correct use of the texture.
  27690. * @param scene Define the scene the texture blongs to
  27691. */
  27692. constructor(scene: Nullable<Scene>);
  27693. /**
  27694. * Get the scene the texture belongs to.
  27695. * @returns the scene or null if undefined
  27696. */
  27697. getScene(): Nullable<Scene>;
  27698. /**
  27699. * Get the texture transform matrix used to offset tile the texture for istance.
  27700. * @returns the transformation matrix
  27701. */
  27702. getTextureMatrix(): Matrix;
  27703. /**
  27704. * Get the texture reflection matrix used to rotate/transform the reflection.
  27705. * @returns the reflection matrix
  27706. */
  27707. getReflectionTextureMatrix(): Matrix;
  27708. /**
  27709. * Get the underlying lower level texture from Babylon.
  27710. * @returns the insternal texture
  27711. */
  27712. getInternalTexture(): Nullable<InternalTexture>;
  27713. /**
  27714. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27715. * @returns true if ready or not blocking
  27716. */
  27717. isReadyOrNotBlocking(): boolean;
  27718. /**
  27719. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27720. * @returns true if fully ready
  27721. */
  27722. isReady(): boolean;
  27723. private _cachedSize;
  27724. /**
  27725. * Get the size of the texture.
  27726. * @returns the texture size.
  27727. */
  27728. getSize(): ISize;
  27729. /**
  27730. * Get the base size of the texture.
  27731. * It can be different from the size if the texture has been resized for POT for instance
  27732. * @returns the base size
  27733. */
  27734. getBaseSize(): ISize;
  27735. /**
  27736. * Update the sampling mode of the texture.
  27737. * Default is Trilinear mode.
  27738. *
  27739. * | Value | Type | Description |
  27740. * | ----- | ------------------ | ----------- |
  27741. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27742. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27743. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27744. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27745. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27746. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27747. * | 7 | NEAREST_LINEAR | |
  27748. * | 8 | NEAREST_NEAREST | |
  27749. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27750. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27751. * | 11 | LINEAR_LINEAR | |
  27752. * | 12 | LINEAR_NEAREST | |
  27753. *
  27754. * > _mag_: magnification filter (close to the viewer)
  27755. * > _min_: minification filter (far from the viewer)
  27756. * > _mip_: filter used between mip map levels
  27757. *@param samplingMode Define the new sampling mode of the texture
  27758. */
  27759. updateSamplingMode(samplingMode: number): void;
  27760. /**
  27761. * Scales the texture if is `canRescale()`
  27762. * @param ratio the resize factor we want to use to rescale
  27763. */
  27764. scale(ratio: number): void;
  27765. /**
  27766. * Get if the texture can rescale.
  27767. */
  27768. readonly canRescale: boolean;
  27769. /** @hidden */
  27770. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27771. /** @hidden */
  27772. _rebuild(): void;
  27773. /**
  27774. * Triggers the load sequence in delayed load mode.
  27775. */
  27776. delayLoad(): void;
  27777. /**
  27778. * Clones the texture.
  27779. * @returns the cloned texture
  27780. */
  27781. clone(): Nullable<BaseTexture>;
  27782. /**
  27783. * Get the texture underlying type (INT, FLOAT...)
  27784. */
  27785. readonly textureType: number;
  27786. /**
  27787. * Get the texture underlying format (RGB, RGBA...)
  27788. */
  27789. readonly textureFormat: number;
  27790. /**
  27791. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27792. * This will returns an RGBA array buffer containing either in values (0-255) or
  27793. * float values (0-1) depending of the underlying buffer type.
  27794. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27795. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27796. * @param buffer defines a user defined buffer to fill with data (can be null)
  27797. * @returns The Array buffer containing the pixels data.
  27798. */
  27799. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27800. /**
  27801. * Release and destroy the underlying lower level texture aka internalTexture.
  27802. */
  27803. releaseInternalTexture(): void;
  27804. /**
  27805. * Get the polynomial representation of the texture data.
  27806. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27807. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27808. */
  27809. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27810. /** @hidden */
  27811. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27812. /** @hidden */
  27813. readonly _lodTextureMid: Nullable<BaseTexture>;
  27814. /** @hidden */
  27815. readonly _lodTextureLow: Nullable<BaseTexture>;
  27816. /**
  27817. * Dispose the texture and release its associated resources.
  27818. */
  27819. dispose(): void;
  27820. /**
  27821. * Serialize the texture into a JSON representation that can be parsed later on.
  27822. * @returns the JSON representation of the texture
  27823. */
  27824. serialize(): any;
  27825. /**
  27826. * Helper function to be called back once a list of texture contains only ready textures.
  27827. * @param textures Define the list of textures to wait for
  27828. * @param callback Define the callback triggered once the entire list will be ready
  27829. */
  27830. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27831. }
  27832. }
  27833. declare module BABYLON {
  27834. /**
  27835. * Class used to store data associated with WebGL texture data for the engine
  27836. * This class should not be used directly
  27837. */
  27838. export class InternalTexture {
  27839. /** @hidden */
  27840. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27841. /**
  27842. * The source of the texture data is unknown
  27843. */
  27844. static DATASOURCE_UNKNOWN: number;
  27845. /**
  27846. * Texture data comes from an URL
  27847. */
  27848. static DATASOURCE_URL: number;
  27849. /**
  27850. * Texture data is only used for temporary storage
  27851. */
  27852. static DATASOURCE_TEMP: number;
  27853. /**
  27854. * Texture data comes from raw data (ArrayBuffer)
  27855. */
  27856. static DATASOURCE_RAW: number;
  27857. /**
  27858. * Texture content is dynamic (video or dynamic texture)
  27859. */
  27860. static DATASOURCE_DYNAMIC: number;
  27861. /**
  27862. * Texture content is generated by rendering to it
  27863. */
  27864. static DATASOURCE_RENDERTARGET: number;
  27865. /**
  27866. * Texture content is part of a multi render target process
  27867. */
  27868. static DATASOURCE_MULTIRENDERTARGET: number;
  27869. /**
  27870. * Texture data comes from a cube data file
  27871. */
  27872. static DATASOURCE_CUBE: number;
  27873. /**
  27874. * Texture data comes from a raw cube data
  27875. */
  27876. static DATASOURCE_CUBERAW: number;
  27877. /**
  27878. * Texture data come from a prefiltered cube data file
  27879. */
  27880. static DATASOURCE_CUBEPREFILTERED: number;
  27881. /**
  27882. * Texture content is raw 3D data
  27883. */
  27884. static DATASOURCE_RAW3D: number;
  27885. /**
  27886. * Texture content is a depth texture
  27887. */
  27888. static DATASOURCE_DEPTHTEXTURE: number;
  27889. /**
  27890. * Texture data comes from a raw cube data encoded with RGBD
  27891. */
  27892. static DATASOURCE_CUBERAW_RGBD: number;
  27893. /**
  27894. * Defines if the texture is ready
  27895. */
  27896. isReady: boolean;
  27897. /**
  27898. * Defines if the texture is a cube texture
  27899. */
  27900. isCube: boolean;
  27901. /**
  27902. * Defines if the texture contains 3D data
  27903. */
  27904. is3D: boolean;
  27905. /**
  27906. * Defines if the texture contains multiview data
  27907. */
  27908. isMultiview: boolean;
  27909. /**
  27910. * Gets the URL used to load this texture
  27911. */
  27912. url: string;
  27913. /**
  27914. * Gets the sampling mode of the texture
  27915. */
  27916. samplingMode: number;
  27917. /**
  27918. * Gets a boolean indicating if the texture needs mipmaps generation
  27919. */
  27920. generateMipMaps: boolean;
  27921. /**
  27922. * Gets the number of samples used by the texture (WebGL2+ only)
  27923. */
  27924. samples: number;
  27925. /**
  27926. * Gets the type of the texture (int, float...)
  27927. */
  27928. type: number;
  27929. /**
  27930. * Gets the format of the texture (RGB, RGBA...)
  27931. */
  27932. format: number;
  27933. /**
  27934. * Observable called when the texture is loaded
  27935. */
  27936. onLoadedObservable: Observable<InternalTexture>;
  27937. /**
  27938. * Gets the width of the texture
  27939. */
  27940. width: number;
  27941. /**
  27942. * Gets the height of the texture
  27943. */
  27944. height: number;
  27945. /**
  27946. * Gets the depth of the texture
  27947. */
  27948. depth: number;
  27949. /**
  27950. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27951. */
  27952. baseWidth: number;
  27953. /**
  27954. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27955. */
  27956. baseHeight: number;
  27957. /**
  27958. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27959. */
  27960. baseDepth: number;
  27961. /**
  27962. * Gets a boolean indicating if the texture is inverted on Y axis
  27963. */
  27964. invertY: boolean;
  27965. /** @hidden */
  27966. _invertVScale: boolean;
  27967. /** @hidden */
  27968. _associatedChannel: number;
  27969. /** @hidden */
  27970. _dataSource: number;
  27971. /** @hidden */
  27972. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27973. /** @hidden */
  27974. _bufferView: Nullable<ArrayBufferView>;
  27975. /** @hidden */
  27976. _bufferViewArray: Nullable<ArrayBufferView[]>;
  27977. /** @hidden */
  27978. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27979. /** @hidden */
  27980. _size: number;
  27981. /** @hidden */
  27982. _extension: string;
  27983. /** @hidden */
  27984. _files: Nullable<string[]>;
  27985. /** @hidden */
  27986. _workingCanvas: Nullable<HTMLCanvasElement>;
  27987. /** @hidden */
  27988. _workingContext: Nullable<CanvasRenderingContext2D>;
  27989. /** @hidden */
  27990. _framebuffer: Nullable<WebGLFramebuffer>;
  27991. /** @hidden */
  27992. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27993. /** @hidden */
  27994. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27995. /** @hidden */
  27996. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27997. /** @hidden */
  27998. _attachments: Nullable<number[]>;
  27999. /** @hidden */
  28000. _cachedCoordinatesMode: Nullable<number>;
  28001. /** @hidden */
  28002. _cachedWrapU: Nullable<number>;
  28003. /** @hidden */
  28004. _cachedWrapV: Nullable<number>;
  28005. /** @hidden */
  28006. _cachedWrapR: Nullable<number>;
  28007. /** @hidden */
  28008. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28009. /** @hidden */
  28010. _isDisabled: boolean;
  28011. /** @hidden */
  28012. _compression: Nullable<string>;
  28013. /** @hidden */
  28014. _generateStencilBuffer: boolean;
  28015. /** @hidden */
  28016. _generateDepthBuffer: boolean;
  28017. /** @hidden */
  28018. _comparisonFunction: number;
  28019. /** @hidden */
  28020. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28021. /** @hidden */
  28022. _lodGenerationScale: number;
  28023. /** @hidden */
  28024. _lodGenerationOffset: number;
  28025. /** @hidden */
  28026. _colorTextureArray: Nullable<WebGLTexture>;
  28027. /** @hidden */
  28028. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28029. /** @hidden */
  28030. _lodTextureHigh: Nullable<BaseTexture>;
  28031. /** @hidden */
  28032. _lodTextureMid: Nullable<BaseTexture>;
  28033. /** @hidden */
  28034. _lodTextureLow: Nullable<BaseTexture>;
  28035. /** @hidden */
  28036. _isRGBD: boolean;
  28037. /** @hidden */
  28038. _linearSpecularLOD: boolean;
  28039. /** @hidden */
  28040. _irradianceTexture: Nullable<BaseTexture>;
  28041. /** @hidden */
  28042. _webGLTexture: Nullable<WebGLTexture>;
  28043. /** @hidden */
  28044. _references: number;
  28045. private _engine;
  28046. /**
  28047. * Gets the Engine the texture belongs to.
  28048. * @returns The babylon engine
  28049. */
  28050. getEngine(): Engine;
  28051. /**
  28052. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28053. */
  28054. readonly dataSource: number;
  28055. /**
  28056. * Creates a new InternalTexture
  28057. * @param engine defines the engine to use
  28058. * @param dataSource defines the type of data that will be used
  28059. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28060. */
  28061. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28062. /**
  28063. * Increments the number of references (ie. the number of Texture that point to it)
  28064. */
  28065. incrementReferences(): void;
  28066. /**
  28067. * Change the size of the texture (not the size of the content)
  28068. * @param width defines the new width
  28069. * @param height defines the new height
  28070. * @param depth defines the new depth (1 by default)
  28071. */
  28072. updateSize(width: int, height: int, depth?: int): void;
  28073. /** @hidden */
  28074. _rebuild(): void;
  28075. /** @hidden */
  28076. _swapAndDie(target: InternalTexture): void;
  28077. /**
  28078. * Dispose the current allocated resources
  28079. */
  28080. dispose(): void;
  28081. }
  28082. }
  28083. declare module BABYLON {
  28084. /**
  28085. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28086. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28087. */
  28088. export class EffectFallbacks {
  28089. private _defines;
  28090. private _currentRank;
  28091. private _maxRank;
  28092. private _mesh;
  28093. /**
  28094. * Removes the fallback from the bound mesh.
  28095. */
  28096. unBindMesh(): void;
  28097. /**
  28098. * Adds a fallback on the specified property.
  28099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28100. * @param define The name of the define in the shader
  28101. */
  28102. addFallback(rank: number, define: string): void;
  28103. /**
  28104. * Sets the mesh to use CPU skinning when needing to fallback.
  28105. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28106. * @param mesh The mesh to use the fallbacks.
  28107. */
  28108. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28109. /**
  28110. * Checks to see if more fallbacks are still availible.
  28111. */
  28112. readonly isMoreFallbacks: boolean;
  28113. /**
  28114. * Removes the defines that should be removed when falling back.
  28115. * @param currentDefines defines the current define statements for the shader.
  28116. * @param effect defines the current effect we try to compile
  28117. * @returns The resulting defines with defines of the current rank removed.
  28118. */
  28119. reduce(currentDefines: string, effect: Effect): string;
  28120. }
  28121. /**
  28122. * Options to be used when creating an effect.
  28123. */
  28124. export class EffectCreationOptions {
  28125. /**
  28126. * Atrributes that will be used in the shader.
  28127. */
  28128. attributes: string[];
  28129. /**
  28130. * Uniform varible names that will be set in the shader.
  28131. */
  28132. uniformsNames: string[];
  28133. /**
  28134. * Uniform buffer varible names that will be set in the shader.
  28135. */
  28136. uniformBuffersNames: string[];
  28137. /**
  28138. * Sampler texture variable names that will be set in the shader.
  28139. */
  28140. samplers: string[];
  28141. /**
  28142. * Define statements that will be set in the shader.
  28143. */
  28144. defines: any;
  28145. /**
  28146. * Possible fallbacks for this effect to improve performance when needed.
  28147. */
  28148. fallbacks: Nullable<EffectFallbacks>;
  28149. /**
  28150. * Callback that will be called when the shader is compiled.
  28151. */
  28152. onCompiled: Nullable<(effect: Effect) => void>;
  28153. /**
  28154. * Callback that will be called if an error occurs during shader compilation.
  28155. */
  28156. onError: Nullable<(effect: Effect, errors: string) => void>;
  28157. /**
  28158. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28159. */
  28160. indexParameters: any;
  28161. /**
  28162. * Max number of lights that can be used in the shader.
  28163. */
  28164. maxSimultaneousLights: number;
  28165. /**
  28166. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28167. */
  28168. transformFeedbackVaryings: Nullable<string[]>;
  28169. }
  28170. /**
  28171. * Effect containing vertex and fragment shader that can be executed on an object.
  28172. */
  28173. export class Effect implements IDisposable {
  28174. /**
  28175. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28176. */
  28177. static ShadersRepository: string;
  28178. /**
  28179. * Name of the effect.
  28180. */
  28181. name: any;
  28182. /**
  28183. * String container all the define statements that should be set on the shader.
  28184. */
  28185. defines: string;
  28186. /**
  28187. * Callback that will be called when the shader is compiled.
  28188. */
  28189. onCompiled: Nullable<(effect: Effect) => void>;
  28190. /**
  28191. * Callback that will be called if an error occurs during shader compilation.
  28192. */
  28193. onError: Nullable<(effect: Effect, errors: string) => void>;
  28194. /**
  28195. * Callback that will be called when effect is bound.
  28196. */
  28197. onBind: Nullable<(effect: Effect) => void>;
  28198. /**
  28199. * Unique ID of the effect.
  28200. */
  28201. uniqueId: number;
  28202. /**
  28203. * Observable that will be called when the shader is compiled.
  28204. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28205. */
  28206. onCompileObservable: Observable<Effect>;
  28207. /**
  28208. * Observable that will be called if an error occurs during shader compilation.
  28209. */
  28210. onErrorObservable: Observable<Effect>;
  28211. /** @hidden */
  28212. _onBindObservable: Nullable<Observable<Effect>>;
  28213. /**
  28214. * Observable that will be called when effect is bound.
  28215. */
  28216. readonly onBindObservable: Observable<Effect>;
  28217. /** @hidden */
  28218. _bonesComputationForcedToCPU: boolean;
  28219. private static _uniqueIdSeed;
  28220. private _engine;
  28221. private _uniformBuffersNames;
  28222. private _uniformsNames;
  28223. private _samplerList;
  28224. private _samplers;
  28225. private _isReady;
  28226. private _compilationError;
  28227. private _attributesNames;
  28228. private _attributes;
  28229. private _uniforms;
  28230. /**
  28231. * Key for the effect.
  28232. * @hidden
  28233. */
  28234. _key: string;
  28235. private _indexParameters;
  28236. private _fallbacks;
  28237. private _vertexSourceCode;
  28238. private _fragmentSourceCode;
  28239. private _vertexSourceCodeOverride;
  28240. private _fragmentSourceCodeOverride;
  28241. private _transformFeedbackVaryings;
  28242. /**
  28243. * Compiled shader to webGL program.
  28244. * @hidden
  28245. */
  28246. _pipelineContext: Nullable<IPipelineContext>;
  28247. private _valueCache;
  28248. private static _baseCache;
  28249. /**
  28250. * Instantiates an effect.
  28251. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28252. * @param baseName Name of the effect.
  28253. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28254. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28255. * @param samplers List of sampler variables that will be passed to the shader.
  28256. * @param engine Engine to be used to render the effect
  28257. * @param defines Define statements to be added to the shader.
  28258. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28259. * @param onCompiled Callback that will be called when the shader is compiled.
  28260. * @param onError Callback that will be called if an error occurs during shader compilation.
  28261. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28262. */
  28263. 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);
  28264. private _useFinalCode;
  28265. /**
  28266. * Unique key for this effect
  28267. */
  28268. readonly key: string;
  28269. /**
  28270. * If the effect has been compiled and prepared.
  28271. * @returns if the effect is compiled and prepared.
  28272. */
  28273. isReady(): boolean;
  28274. /**
  28275. * The engine the effect was initialized with.
  28276. * @returns the engine.
  28277. */
  28278. getEngine(): Engine;
  28279. /**
  28280. * The pipeline context for this effect
  28281. * @returns the associated pipeline context
  28282. */
  28283. getPipelineContext(): Nullable<IPipelineContext>;
  28284. /**
  28285. * The set of names of attribute variables for the shader.
  28286. * @returns An array of attribute names.
  28287. */
  28288. getAttributesNames(): string[];
  28289. /**
  28290. * Returns the attribute at the given index.
  28291. * @param index The index of the attribute.
  28292. * @returns The location of the attribute.
  28293. */
  28294. getAttributeLocation(index: number): number;
  28295. /**
  28296. * Returns the attribute based on the name of the variable.
  28297. * @param name of the attribute to look up.
  28298. * @returns the attribute location.
  28299. */
  28300. getAttributeLocationByName(name: string): number;
  28301. /**
  28302. * The number of attributes.
  28303. * @returns the numnber of attributes.
  28304. */
  28305. getAttributesCount(): number;
  28306. /**
  28307. * Gets the index of a uniform variable.
  28308. * @param uniformName of the uniform to look up.
  28309. * @returns the index.
  28310. */
  28311. getUniformIndex(uniformName: string): number;
  28312. /**
  28313. * Returns the attribute based on the name of the variable.
  28314. * @param uniformName of the uniform to look up.
  28315. * @returns the location of the uniform.
  28316. */
  28317. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28318. /**
  28319. * Returns an array of sampler variable names
  28320. * @returns The array of sampler variable neames.
  28321. */
  28322. getSamplers(): string[];
  28323. /**
  28324. * The error from the last compilation.
  28325. * @returns the error string.
  28326. */
  28327. getCompilationError(): string;
  28328. /**
  28329. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28330. * @param func The callback to be used.
  28331. */
  28332. executeWhenCompiled(func: (effect: Effect) => void): void;
  28333. private _checkIsReady;
  28334. /** @hidden */
  28335. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28336. /** @hidden */
  28337. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28338. /** @hidden */
  28339. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28340. /**
  28341. * Recompiles the webGL program
  28342. * @param vertexSourceCode The source code for the vertex shader.
  28343. * @param fragmentSourceCode The source code for the fragment shader.
  28344. * @param onCompiled Callback called when completed.
  28345. * @param onError Callback called on error.
  28346. * @hidden
  28347. */
  28348. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28349. /**
  28350. * Prepares the effect
  28351. * @hidden
  28352. */
  28353. _prepareEffect(): void;
  28354. /**
  28355. * Checks if the effect is supported. (Must be called after compilation)
  28356. */
  28357. readonly isSupported: boolean;
  28358. /**
  28359. * Binds a texture to the engine to be used as output of the shader.
  28360. * @param channel Name of the output variable.
  28361. * @param texture Texture to bind.
  28362. * @hidden
  28363. */
  28364. _bindTexture(channel: string, texture: InternalTexture): void;
  28365. /**
  28366. * Sets a texture on the engine to be used in the shader.
  28367. * @param channel Name of the sampler variable.
  28368. * @param texture Texture to set.
  28369. */
  28370. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28371. /**
  28372. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28373. * @param channel Name of the sampler variable.
  28374. * @param texture Texture to set.
  28375. */
  28376. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28377. /**
  28378. * Sets an array of textures on the engine to be used in the shader.
  28379. * @param channel Name of the variable.
  28380. * @param textures Textures to set.
  28381. */
  28382. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28383. /**
  28384. * 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)
  28385. * @param channel Name of the sampler variable.
  28386. * @param postProcess Post process to get the input texture from.
  28387. */
  28388. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28389. /**
  28390. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28391. * 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)
  28392. * @param channel Name of the sampler variable.
  28393. * @param postProcess Post process to get the output texture from.
  28394. */
  28395. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28396. /** @hidden */
  28397. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28398. /** @hidden */
  28399. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28400. /** @hidden */
  28401. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28402. /** @hidden */
  28403. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28404. /**
  28405. * Binds a buffer to a uniform.
  28406. * @param buffer Buffer to bind.
  28407. * @param name Name of the uniform variable to bind to.
  28408. */
  28409. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28410. /**
  28411. * Binds block to a uniform.
  28412. * @param blockName Name of the block to bind.
  28413. * @param index Index to bind.
  28414. */
  28415. bindUniformBlock(blockName: string, index: number): void;
  28416. /**
  28417. * Sets an interger value on a uniform variable.
  28418. * @param uniformName Name of the variable.
  28419. * @param value Value to be set.
  28420. * @returns this effect.
  28421. */
  28422. setInt(uniformName: string, value: number): Effect;
  28423. /**
  28424. * Sets an int array on a uniform variable.
  28425. * @param uniformName Name of the variable.
  28426. * @param array array to be set.
  28427. * @returns this effect.
  28428. */
  28429. setIntArray(uniformName: string, array: Int32Array): Effect;
  28430. /**
  28431. * 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)
  28432. * @param uniformName Name of the variable.
  28433. * @param array array to be set.
  28434. * @returns this effect.
  28435. */
  28436. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28437. /**
  28438. * 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)
  28439. * @param uniformName Name of the variable.
  28440. * @param array array to be set.
  28441. * @returns this effect.
  28442. */
  28443. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28444. /**
  28445. * 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)
  28446. * @param uniformName Name of the variable.
  28447. * @param array array to be set.
  28448. * @returns this effect.
  28449. */
  28450. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28451. /**
  28452. * Sets an float array on a uniform variable.
  28453. * @param uniformName Name of the variable.
  28454. * @param array array to be set.
  28455. * @returns this effect.
  28456. */
  28457. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28458. /**
  28459. * 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)
  28460. * @param uniformName Name of the variable.
  28461. * @param array array to be set.
  28462. * @returns this effect.
  28463. */
  28464. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28465. /**
  28466. * 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)
  28467. * @param uniformName Name of the variable.
  28468. * @param array array to be set.
  28469. * @returns this effect.
  28470. */
  28471. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28472. /**
  28473. * 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)
  28474. * @param uniformName Name of the variable.
  28475. * @param array array to be set.
  28476. * @returns this effect.
  28477. */
  28478. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28479. /**
  28480. * Sets an array on a uniform variable.
  28481. * @param uniformName Name of the variable.
  28482. * @param array array to be set.
  28483. * @returns this effect.
  28484. */
  28485. setArray(uniformName: string, array: number[]): Effect;
  28486. /**
  28487. * 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)
  28488. * @param uniformName Name of the variable.
  28489. * @param array array to be set.
  28490. * @returns this effect.
  28491. */
  28492. setArray2(uniformName: string, array: number[]): Effect;
  28493. /**
  28494. * 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)
  28495. * @param uniformName Name of the variable.
  28496. * @param array array to be set.
  28497. * @returns this effect.
  28498. */
  28499. setArray3(uniformName: string, array: number[]): Effect;
  28500. /**
  28501. * 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)
  28502. * @param uniformName Name of the variable.
  28503. * @param array array to be set.
  28504. * @returns this effect.
  28505. */
  28506. setArray4(uniformName: string, array: number[]): Effect;
  28507. /**
  28508. * Sets matrices on a uniform variable.
  28509. * @param uniformName Name of the variable.
  28510. * @param matrices matrices to be set.
  28511. * @returns this effect.
  28512. */
  28513. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28514. /**
  28515. * Sets matrix on a uniform variable.
  28516. * @param uniformName Name of the variable.
  28517. * @param matrix matrix to be set.
  28518. * @returns this effect.
  28519. */
  28520. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28521. /**
  28522. * 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)
  28523. * @param uniformName Name of the variable.
  28524. * @param matrix matrix to be set.
  28525. * @returns this effect.
  28526. */
  28527. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28528. /**
  28529. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28530. * @param uniformName Name of the variable.
  28531. * @param matrix matrix to be set.
  28532. * @returns this effect.
  28533. */
  28534. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28535. /**
  28536. * Sets a float on a uniform variable.
  28537. * @param uniformName Name of the variable.
  28538. * @param value value to be set.
  28539. * @returns this effect.
  28540. */
  28541. setFloat(uniformName: string, value: number): Effect;
  28542. /**
  28543. * Sets a boolean on a uniform variable.
  28544. * @param uniformName Name of the variable.
  28545. * @param bool value to be set.
  28546. * @returns this effect.
  28547. */
  28548. setBool(uniformName: string, bool: boolean): Effect;
  28549. /**
  28550. * Sets a Vector2 on a uniform variable.
  28551. * @param uniformName Name of the variable.
  28552. * @param vector2 vector2 to be set.
  28553. * @returns this effect.
  28554. */
  28555. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28556. /**
  28557. * Sets a float2 on a uniform variable.
  28558. * @param uniformName Name of the variable.
  28559. * @param x First float in float2.
  28560. * @param y Second float in float2.
  28561. * @returns this effect.
  28562. */
  28563. setFloat2(uniformName: string, x: number, y: number): Effect;
  28564. /**
  28565. * Sets a Vector3 on a uniform variable.
  28566. * @param uniformName Name of the variable.
  28567. * @param vector3 Value to be set.
  28568. * @returns this effect.
  28569. */
  28570. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28571. /**
  28572. * Sets a float3 on a uniform variable.
  28573. * @param uniformName Name of the variable.
  28574. * @param x First float in float3.
  28575. * @param y Second float in float3.
  28576. * @param z Third float in float3.
  28577. * @returns this effect.
  28578. */
  28579. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28580. /**
  28581. * Sets a Vector4 on a uniform variable.
  28582. * @param uniformName Name of the variable.
  28583. * @param vector4 Value to be set.
  28584. * @returns this effect.
  28585. */
  28586. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28587. /**
  28588. * Sets a float4 on a uniform variable.
  28589. * @param uniformName Name of the variable.
  28590. * @param x First float in float4.
  28591. * @param y Second float in float4.
  28592. * @param z Third float in float4.
  28593. * @param w Fourth float in float4.
  28594. * @returns this effect.
  28595. */
  28596. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28597. /**
  28598. * Sets a Color3 on a uniform variable.
  28599. * @param uniformName Name of the variable.
  28600. * @param color3 Value to be set.
  28601. * @returns this effect.
  28602. */
  28603. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28604. /**
  28605. * Sets a Color4 on a uniform variable.
  28606. * @param uniformName Name of the variable.
  28607. * @param color3 Value to be set.
  28608. * @param alpha Alpha value to be set.
  28609. * @returns this effect.
  28610. */
  28611. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28612. /**
  28613. * Sets a Color4 on a uniform variable
  28614. * @param uniformName defines the name of the variable
  28615. * @param color4 defines the value to be set
  28616. * @returns this effect.
  28617. */
  28618. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28619. /** Release all associated resources */
  28620. dispose(): void;
  28621. /**
  28622. * This function will add a new shader to the shader store
  28623. * @param name the name of the shader
  28624. * @param pixelShader optional pixel shader content
  28625. * @param vertexShader optional vertex shader content
  28626. */
  28627. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28628. /**
  28629. * Store of each shader (The can be looked up using effect.key)
  28630. */
  28631. static ShadersStore: {
  28632. [key: string]: string;
  28633. };
  28634. /**
  28635. * Store of each included file for a shader (The can be looked up using effect.key)
  28636. */
  28637. static IncludesShadersStore: {
  28638. [key: string]: string;
  28639. };
  28640. /**
  28641. * Resets the cache of effects.
  28642. */
  28643. static ResetCache(): void;
  28644. }
  28645. }
  28646. declare module BABYLON {
  28647. /**
  28648. * Uniform buffer objects.
  28649. *
  28650. * Handles blocks of uniform on the GPU.
  28651. *
  28652. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28653. *
  28654. * For more information, please refer to :
  28655. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28656. */
  28657. export class UniformBuffer {
  28658. private _engine;
  28659. private _buffer;
  28660. private _data;
  28661. private _bufferData;
  28662. private _dynamic?;
  28663. private _uniformLocations;
  28664. private _uniformSizes;
  28665. private _uniformLocationPointer;
  28666. private _needSync;
  28667. private _noUBO;
  28668. private _currentEffect;
  28669. private static _MAX_UNIFORM_SIZE;
  28670. private static _tempBuffer;
  28671. /**
  28672. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28673. * This is dynamic to allow compat with webgl 1 and 2.
  28674. * You will need to pass the name of the uniform as well as the value.
  28675. */
  28676. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28677. /**
  28678. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28679. * This is dynamic to allow compat with webgl 1 and 2.
  28680. * You will need to pass the name of the uniform as well as the value.
  28681. */
  28682. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28683. /**
  28684. * Lambda to Update a single float in a uniform buffer.
  28685. * This is dynamic to allow compat with webgl 1 and 2.
  28686. * You will need to pass the name of the uniform as well as the value.
  28687. */
  28688. updateFloat: (name: string, x: number) => void;
  28689. /**
  28690. * Lambda to Update a vec2 of float in a uniform buffer.
  28691. * This is dynamic to allow compat with webgl 1 and 2.
  28692. * You will need to pass the name of the uniform as well as the value.
  28693. */
  28694. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28695. /**
  28696. * Lambda to Update a vec3 of float in a uniform buffer.
  28697. * This is dynamic to allow compat with webgl 1 and 2.
  28698. * You will need to pass the name of the uniform as well as the value.
  28699. */
  28700. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28701. /**
  28702. * Lambda to Update a vec4 of float in a uniform buffer.
  28703. * This is dynamic to allow compat with webgl 1 and 2.
  28704. * You will need to pass the name of the uniform as well as the value.
  28705. */
  28706. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28707. /**
  28708. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28709. * This is dynamic to allow compat with webgl 1 and 2.
  28710. * You will need to pass the name of the uniform as well as the value.
  28711. */
  28712. updateMatrix: (name: string, mat: Matrix) => void;
  28713. /**
  28714. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28715. * This is dynamic to allow compat with webgl 1 and 2.
  28716. * You will need to pass the name of the uniform as well as the value.
  28717. */
  28718. updateVector3: (name: string, vector: Vector3) => void;
  28719. /**
  28720. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28721. * This is dynamic to allow compat with webgl 1 and 2.
  28722. * You will need to pass the name of the uniform as well as the value.
  28723. */
  28724. updateVector4: (name: string, vector: Vector4) => void;
  28725. /**
  28726. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28727. * This is dynamic to allow compat with webgl 1 and 2.
  28728. * You will need to pass the name of the uniform as well as the value.
  28729. */
  28730. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28731. /**
  28732. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28733. * This is dynamic to allow compat with webgl 1 and 2.
  28734. * You will need to pass the name of the uniform as well as the value.
  28735. */
  28736. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28737. /**
  28738. * Instantiates a new Uniform buffer objects.
  28739. *
  28740. * Handles blocks of uniform on the GPU.
  28741. *
  28742. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28743. *
  28744. * For more information, please refer to :
  28745. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28746. * @param engine Define the engine the buffer is associated with
  28747. * @param data Define the data contained in the buffer
  28748. * @param dynamic Define if the buffer is updatable
  28749. */
  28750. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28751. /**
  28752. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28753. * or just falling back on setUniformXXX calls.
  28754. */
  28755. readonly useUbo: boolean;
  28756. /**
  28757. * Indicates if the WebGL underlying uniform buffer is in sync
  28758. * with the javascript cache data.
  28759. */
  28760. readonly isSync: boolean;
  28761. /**
  28762. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28763. * Also, a dynamic UniformBuffer will disable cache verification and always
  28764. * update the underlying WebGL uniform buffer to the GPU.
  28765. * @returns if Dynamic, otherwise false
  28766. */
  28767. isDynamic(): boolean;
  28768. /**
  28769. * The data cache on JS side.
  28770. * @returns the underlying data as a float array
  28771. */
  28772. getData(): Float32Array;
  28773. /**
  28774. * The underlying WebGL Uniform buffer.
  28775. * @returns the webgl buffer
  28776. */
  28777. getBuffer(): Nullable<DataBuffer>;
  28778. /**
  28779. * std140 layout specifies how to align data within an UBO structure.
  28780. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28781. * for specs.
  28782. */
  28783. private _fillAlignment;
  28784. /**
  28785. * Adds an uniform in the buffer.
  28786. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28787. * for the layout to be correct !
  28788. * @param name Name of the uniform, as used in the uniform block in the shader.
  28789. * @param size Data size, or data directly.
  28790. */
  28791. addUniform(name: string, size: number | number[]): void;
  28792. /**
  28793. * Adds a Matrix 4x4 to the uniform buffer.
  28794. * @param name Name of the uniform, as used in the uniform block in the shader.
  28795. * @param mat A 4x4 matrix.
  28796. */
  28797. addMatrix(name: string, mat: Matrix): void;
  28798. /**
  28799. * Adds a vec2 to the uniform buffer.
  28800. * @param name Name of the uniform, as used in the uniform block in the shader.
  28801. * @param x Define the x component value of the vec2
  28802. * @param y Define the y component value of the vec2
  28803. */
  28804. addFloat2(name: string, x: number, y: number): void;
  28805. /**
  28806. * Adds a vec3 to the uniform buffer.
  28807. * @param name Name of the uniform, as used in the uniform block in the shader.
  28808. * @param x Define the x component value of the vec3
  28809. * @param y Define the y component value of the vec3
  28810. * @param z Define the z component value of the vec3
  28811. */
  28812. addFloat3(name: string, x: number, y: number, z: number): void;
  28813. /**
  28814. * Adds a vec3 to the uniform buffer.
  28815. * @param name Name of the uniform, as used in the uniform block in the shader.
  28816. * @param color Define the vec3 from a Color
  28817. */
  28818. addColor3(name: string, color: Color3): void;
  28819. /**
  28820. * Adds a vec4 to the uniform buffer.
  28821. * @param name Name of the uniform, as used in the uniform block in the shader.
  28822. * @param color Define the rgb components from a Color
  28823. * @param alpha Define the a component of the vec4
  28824. */
  28825. addColor4(name: string, color: Color3, alpha: number): void;
  28826. /**
  28827. * Adds a vec3 to the uniform buffer.
  28828. * @param name Name of the uniform, as used in the uniform block in the shader.
  28829. * @param vector Define the vec3 components from a Vector
  28830. */
  28831. addVector3(name: string, vector: Vector3): void;
  28832. /**
  28833. * Adds a Matrix 3x3 to the uniform buffer.
  28834. * @param name Name of the uniform, as used in the uniform block in the shader.
  28835. */
  28836. addMatrix3x3(name: string): void;
  28837. /**
  28838. * Adds a Matrix 2x2 to the uniform buffer.
  28839. * @param name Name of the uniform, as used in the uniform block in the shader.
  28840. */
  28841. addMatrix2x2(name: string): void;
  28842. /**
  28843. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28844. */
  28845. create(): void;
  28846. /** @hidden */
  28847. _rebuild(): void;
  28848. /**
  28849. * Updates the WebGL Uniform Buffer on the GPU.
  28850. * If the `dynamic` flag is set to true, no cache comparison is done.
  28851. * Otherwise, the buffer will be updated only if the cache differs.
  28852. */
  28853. update(): void;
  28854. /**
  28855. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28856. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28857. * @param data Define the flattened data
  28858. * @param size Define the size of the data.
  28859. */
  28860. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28861. private _updateMatrix3x3ForUniform;
  28862. private _updateMatrix3x3ForEffect;
  28863. private _updateMatrix2x2ForEffect;
  28864. private _updateMatrix2x2ForUniform;
  28865. private _updateFloatForEffect;
  28866. private _updateFloatForUniform;
  28867. private _updateFloat2ForEffect;
  28868. private _updateFloat2ForUniform;
  28869. private _updateFloat3ForEffect;
  28870. private _updateFloat3ForUniform;
  28871. private _updateFloat4ForEffect;
  28872. private _updateFloat4ForUniform;
  28873. private _updateMatrixForEffect;
  28874. private _updateMatrixForUniform;
  28875. private _updateVector3ForEffect;
  28876. private _updateVector3ForUniform;
  28877. private _updateVector4ForEffect;
  28878. private _updateVector4ForUniform;
  28879. private _updateColor3ForEffect;
  28880. private _updateColor3ForUniform;
  28881. private _updateColor4ForEffect;
  28882. private _updateColor4ForUniform;
  28883. /**
  28884. * Sets a sampler uniform on the effect.
  28885. * @param name Define the name of the sampler.
  28886. * @param texture Define the texture to set in the sampler
  28887. */
  28888. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28889. /**
  28890. * Directly updates the value of the uniform in the cache AND on the GPU.
  28891. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28892. * @param data Define the flattened data
  28893. */
  28894. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28895. /**
  28896. * Binds this uniform buffer to an effect.
  28897. * @param effect Define the effect to bind the buffer to
  28898. * @param name Name of the uniform block in the shader.
  28899. */
  28900. bindToEffect(effect: Effect, name: string): void;
  28901. /**
  28902. * Disposes the uniform buffer.
  28903. */
  28904. dispose(): void;
  28905. }
  28906. }
  28907. declare module BABYLON {
  28908. /**
  28909. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28911. */
  28912. export class Analyser {
  28913. /**
  28914. * Gets or sets the smoothing
  28915. * @ignorenaming
  28916. */
  28917. SMOOTHING: number;
  28918. /**
  28919. * Gets or sets the FFT table size
  28920. * @ignorenaming
  28921. */
  28922. FFT_SIZE: number;
  28923. /**
  28924. * Gets or sets the bar graph amplitude
  28925. * @ignorenaming
  28926. */
  28927. BARGRAPHAMPLITUDE: number;
  28928. /**
  28929. * Gets or sets the position of the debug canvas
  28930. * @ignorenaming
  28931. */
  28932. DEBUGCANVASPOS: {
  28933. x: number;
  28934. y: number;
  28935. };
  28936. /**
  28937. * Gets or sets the debug canvas size
  28938. * @ignorenaming
  28939. */
  28940. DEBUGCANVASSIZE: {
  28941. width: number;
  28942. height: number;
  28943. };
  28944. private _byteFreqs;
  28945. private _byteTime;
  28946. private _floatFreqs;
  28947. private _webAudioAnalyser;
  28948. private _debugCanvas;
  28949. private _debugCanvasContext;
  28950. private _scene;
  28951. private _registerFunc;
  28952. private _audioEngine;
  28953. /**
  28954. * Creates a new analyser
  28955. * @param scene defines hosting scene
  28956. */
  28957. constructor(scene: Scene);
  28958. /**
  28959. * Get the number of data values you will have to play with for the visualization
  28960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28961. * @returns a number
  28962. */
  28963. getFrequencyBinCount(): number;
  28964. /**
  28965. * Gets the current frequency data as a byte array
  28966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28967. * @returns a Uint8Array
  28968. */
  28969. getByteFrequencyData(): Uint8Array;
  28970. /**
  28971. * Gets the current waveform as a byte array
  28972. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28973. * @returns a Uint8Array
  28974. */
  28975. getByteTimeDomainData(): Uint8Array;
  28976. /**
  28977. * Gets the current frequency data as a float array
  28978. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28979. * @returns a Float32Array
  28980. */
  28981. getFloatFrequencyData(): Float32Array;
  28982. /**
  28983. * Renders the debug canvas
  28984. */
  28985. drawDebugCanvas(): void;
  28986. /**
  28987. * Stops rendering the debug canvas and removes it
  28988. */
  28989. stopDebugCanvas(): void;
  28990. /**
  28991. * Connects two audio nodes
  28992. * @param inputAudioNode defines first node to connect
  28993. * @param outputAudioNode defines second node to connect
  28994. */
  28995. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28996. /**
  28997. * Releases all associated resources
  28998. */
  28999. dispose(): void;
  29000. }
  29001. }
  29002. declare module BABYLON {
  29003. /**
  29004. * This represents an audio engine and it is responsible
  29005. * to play, synchronize and analyse sounds throughout the application.
  29006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29007. */
  29008. export interface IAudioEngine extends IDisposable {
  29009. /**
  29010. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29011. */
  29012. readonly canUseWebAudio: boolean;
  29013. /**
  29014. * Gets the current AudioContext if available.
  29015. */
  29016. readonly audioContext: Nullable<AudioContext>;
  29017. /**
  29018. * The master gain node defines the global audio volume of your audio engine.
  29019. */
  29020. readonly masterGain: GainNode;
  29021. /**
  29022. * Gets whether or not mp3 are supported by your browser.
  29023. */
  29024. readonly isMP3supported: boolean;
  29025. /**
  29026. * Gets whether or not ogg are supported by your browser.
  29027. */
  29028. readonly isOGGsupported: boolean;
  29029. /**
  29030. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29031. * @ignoreNaming
  29032. */
  29033. WarnedWebAudioUnsupported: boolean;
  29034. /**
  29035. * Defines if the audio engine relies on a custom unlocked button.
  29036. * In this case, the embedded button will not be displayed.
  29037. */
  29038. useCustomUnlockedButton: boolean;
  29039. /**
  29040. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29041. */
  29042. readonly unlocked: boolean;
  29043. /**
  29044. * Event raised when audio has been unlocked on the browser.
  29045. */
  29046. onAudioUnlockedObservable: Observable<AudioEngine>;
  29047. /**
  29048. * Event raised when audio has been locked on the browser.
  29049. */
  29050. onAudioLockedObservable: Observable<AudioEngine>;
  29051. /**
  29052. * Flags the audio engine in Locked state.
  29053. * This happens due to new browser policies preventing audio to autoplay.
  29054. */
  29055. lock(): void;
  29056. /**
  29057. * Unlocks the audio engine once a user action has been done on the dom.
  29058. * This is helpful to resume play once browser policies have been satisfied.
  29059. */
  29060. unlock(): void;
  29061. }
  29062. /**
  29063. * This represents the default audio engine used in babylon.
  29064. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29066. */
  29067. export class AudioEngine implements IAudioEngine {
  29068. private _audioContext;
  29069. private _audioContextInitialized;
  29070. private _muteButton;
  29071. private _hostElement;
  29072. /**
  29073. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29074. */
  29075. canUseWebAudio: boolean;
  29076. /**
  29077. * The master gain node defines the global audio volume of your audio engine.
  29078. */
  29079. masterGain: GainNode;
  29080. /**
  29081. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29082. * @ignoreNaming
  29083. */
  29084. WarnedWebAudioUnsupported: boolean;
  29085. /**
  29086. * Gets whether or not mp3 are supported by your browser.
  29087. */
  29088. isMP3supported: boolean;
  29089. /**
  29090. * Gets whether or not ogg are supported by your browser.
  29091. */
  29092. isOGGsupported: boolean;
  29093. /**
  29094. * Gets whether audio has been unlocked on the device.
  29095. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29096. * a user interaction has happened.
  29097. */
  29098. unlocked: boolean;
  29099. /**
  29100. * Defines if the audio engine relies on a custom unlocked button.
  29101. * In this case, the embedded button will not be displayed.
  29102. */
  29103. useCustomUnlockedButton: boolean;
  29104. /**
  29105. * Event raised when audio has been unlocked on the browser.
  29106. */
  29107. onAudioUnlockedObservable: Observable<AudioEngine>;
  29108. /**
  29109. * Event raised when audio has been locked on the browser.
  29110. */
  29111. onAudioLockedObservable: Observable<AudioEngine>;
  29112. /**
  29113. * Gets the current AudioContext if available.
  29114. */
  29115. readonly audioContext: Nullable<AudioContext>;
  29116. private _connectedAnalyser;
  29117. /**
  29118. * Instantiates a new audio engine.
  29119. *
  29120. * There should be only one per page as some browsers restrict the number
  29121. * of audio contexts you can create.
  29122. * @param hostElement defines the host element where to display the mute icon if necessary
  29123. */
  29124. constructor(hostElement?: Nullable<HTMLElement>);
  29125. /**
  29126. * Flags the audio engine in Locked state.
  29127. * This happens due to new browser policies preventing audio to autoplay.
  29128. */
  29129. lock(): void;
  29130. /**
  29131. * Unlocks the audio engine once a user action has been done on the dom.
  29132. * This is helpful to resume play once browser policies have been satisfied.
  29133. */
  29134. unlock(): void;
  29135. private _resumeAudioContext;
  29136. private _initializeAudioContext;
  29137. private _tryToRun;
  29138. private _triggerRunningState;
  29139. private _triggerSuspendedState;
  29140. private _displayMuteButton;
  29141. private _moveButtonToTopLeft;
  29142. private _onResize;
  29143. private _hideMuteButton;
  29144. /**
  29145. * Destroy and release the resources associated with the audio ccontext.
  29146. */
  29147. dispose(): void;
  29148. /**
  29149. * Gets the global volume sets on the master gain.
  29150. * @returns the global volume if set or -1 otherwise
  29151. */
  29152. getGlobalVolume(): number;
  29153. /**
  29154. * Sets the global volume of your experience (sets on the master gain).
  29155. * @param newVolume Defines the new global volume of the application
  29156. */
  29157. setGlobalVolume(newVolume: number): void;
  29158. /**
  29159. * Connect the audio engine to an audio analyser allowing some amazing
  29160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29162. * @param analyser The analyser to connect to the engine
  29163. */
  29164. connectToAnalyser(analyser: Analyser): void;
  29165. }
  29166. }
  29167. declare module BABYLON {
  29168. /**
  29169. * Interface used to present a loading screen while loading a scene
  29170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29171. */
  29172. export interface ILoadingScreen {
  29173. /**
  29174. * Function called to display the loading screen
  29175. */
  29176. displayLoadingUI: () => void;
  29177. /**
  29178. * Function called to hide the loading screen
  29179. */
  29180. hideLoadingUI: () => void;
  29181. /**
  29182. * Gets or sets the color to use for the background
  29183. */
  29184. loadingUIBackgroundColor: string;
  29185. /**
  29186. * Gets or sets the text to display while loading
  29187. */
  29188. loadingUIText: string;
  29189. }
  29190. /**
  29191. * Class used for the default loading screen
  29192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29193. */
  29194. export class DefaultLoadingScreen implements ILoadingScreen {
  29195. private _renderingCanvas;
  29196. private _loadingText;
  29197. private _loadingDivBackgroundColor;
  29198. private _loadingDiv;
  29199. private _loadingTextDiv;
  29200. /** Gets or sets the logo url to use for the default loading screen */
  29201. static DefaultLogoUrl: string;
  29202. /** Gets or sets the spinner url to use for the default loading screen */
  29203. static DefaultSpinnerUrl: string;
  29204. /**
  29205. * Creates a new default loading screen
  29206. * @param _renderingCanvas defines the canvas used to render the scene
  29207. * @param _loadingText defines the default text to display
  29208. * @param _loadingDivBackgroundColor defines the default background color
  29209. */
  29210. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29211. /**
  29212. * Function called to display the loading screen
  29213. */
  29214. displayLoadingUI(): void;
  29215. /**
  29216. * Function called to hide the loading screen
  29217. */
  29218. hideLoadingUI(): void;
  29219. /**
  29220. * Gets or sets the text to display while loading
  29221. */
  29222. loadingUIText: string;
  29223. /**
  29224. * Gets or sets the color to use for the background
  29225. */
  29226. loadingUIBackgroundColor: string;
  29227. private _resizeLoadingUI;
  29228. }
  29229. }
  29230. declare module BABYLON {
  29231. /** @hidden */
  29232. export class WebGLPipelineContext implements IPipelineContext {
  29233. engine: Engine;
  29234. program: Nullable<WebGLProgram>;
  29235. context?: WebGLRenderingContext;
  29236. vertexShader?: WebGLShader;
  29237. fragmentShader?: WebGLShader;
  29238. isParallelCompiled: boolean;
  29239. onCompiled?: () => void;
  29240. transformFeedback?: WebGLTransformFeedback | null;
  29241. readonly isAsync: boolean;
  29242. readonly isReady: boolean;
  29243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29244. }
  29245. }
  29246. declare module BABYLON {
  29247. /** @hidden */
  29248. export class WebGLDataBuffer extends DataBuffer {
  29249. private _buffer;
  29250. constructor(resource: WebGLBuffer);
  29251. readonly underlyingResource: any;
  29252. }
  29253. }
  29254. declare module BABYLON {
  29255. /** @hidden */
  29256. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29257. attributeProcessor(attribute: string): string;
  29258. varyingProcessor(varying: string, isFragment: boolean): string;
  29259. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29260. }
  29261. }
  29262. declare module BABYLON {
  29263. /**
  29264. * This class is used to track a performance counter which is number based.
  29265. * The user has access to many properties which give statistics of different nature.
  29266. *
  29267. * The implementer can track two kinds of Performance Counter: time and count.
  29268. * 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.
  29269. * 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.
  29270. */
  29271. export class PerfCounter {
  29272. /**
  29273. * Gets or sets a global boolean to turn on and off all the counters
  29274. */
  29275. static Enabled: boolean;
  29276. /**
  29277. * Returns the smallest value ever
  29278. */
  29279. readonly min: number;
  29280. /**
  29281. * Returns the biggest value ever
  29282. */
  29283. readonly max: number;
  29284. /**
  29285. * Returns the average value since the performance counter is running
  29286. */
  29287. readonly average: number;
  29288. /**
  29289. * Returns the average value of the last second the counter was monitored
  29290. */
  29291. readonly lastSecAverage: number;
  29292. /**
  29293. * Returns the current value
  29294. */
  29295. readonly current: number;
  29296. /**
  29297. * Gets the accumulated total
  29298. */
  29299. readonly total: number;
  29300. /**
  29301. * Gets the total value count
  29302. */
  29303. readonly count: number;
  29304. /**
  29305. * Creates a new counter
  29306. */
  29307. constructor();
  29308. /**
  29309. * Call this method to start monitoring a new frame.
  29310. * 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.
  29311. */
  29312. fetchNewFrame(): void;
  29313. /**
  29314. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29315. * @param newCount the count value to add to the monitored count
  29316. * @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.
  29317. */
  29318. addCount(newCount: number, fetchResult: boolean): void;
  29319. /**
  29320. * Start monitoring this performance counter
  29321. */
  29322. beginMonitoring(): void;
  29323. /**
  29324. * Compute the time lapsed since the previous beginMonitoring() call.
  29325. * @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
  29326. */
  29327. endMonitoring(newFrame?: boolean): void;
  29328. private _fetchResult;
  29329. private _startMonitoringTime;
  29330. private _min;
  29331. private _max;
  29332. private _average;
  29333. private _current;
  29334. private _totalValueCount;
  29335. private _totalAccumulated;
  29336. private _lastSecAverage;
  29337. private _lastSecAccumulated;
  29338. private _lastSecTime;
  29339. private _lastSecValueCount;
  29340. }
  29341. }
  29342. declare module BABYLON {
  29343. /**
  29344. * Interface for any object that can request an animation frame
  29345. */
  29346. export interface ICustomAnimationFrameRequester {
  29347. /**
  29348. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29349. */
  29350. renderFunction?: Function;
  29351. /**
  29352. * Called to request the next frame to render to
  29353. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29354. */
  29355. requestAnimationFrame: Function;
  29356. /**
  29357. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29358. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29359. */
  29360. requestID?: number;
  29361. }
  29362. }
  29363. declare module BABYLON {
  29364. /**
  29365. * Settings for finer control over video usage
  29366. */
  29367. export interface VideoTextureSettings {
  29368. /**
  29369. * Applies `autoplay` to video, if specified
  29370. */
  29371. autoPlay?: boolean;
  29372. /**
  29373. * Applies `loop` to video, if specified
  29374. */
  29375. loop?: boolean;
  29376. /**
  29377. * Automatically updates internal texture from video at every frame in the render loop
  29378. */
  29379. autoUpdateTexture: boolean;
  29380. /**
  29381. * Image src displayed during the video loading or until the user interacts with the video.
  29382. */
  29383. poster?: string;
  29384. }
  29385. /**
  29386. * If you want to display a video in your scene, this is the special texture for that.
  29387. * This special texture works similar to other textures, with the exception of a few parameters.
  29388. * @see https://doc.babylonjs.com/how_to/video_texture
  29389. */
  29390. export class VideoTexture extends Texture {
  29391. /**
  29392. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29393. */
  29394. readonly autoUpdateTexture: boolean;
  29395. /**
  29396. * The video instance used by the texture internally
  29397. */
  29398. readonly video: HTMLVideoElement;
  29399. private _onUserActionRequestedObservable;
  29400. /**
  29401. * Event triggerd when a dom action is required by the user to play the video.
  29402. * This happens due to recent changes in browser policies preventing video to auto start.
  29403. */
  29404. readonly onUserActionRequestedObservable: Observable<Texture>;
  29405. private _generateMipMaps;
  29406. private _engine;
  29407. private _stillImageCaptured;
  29408. private _displayingPosterTexture;
  29409. private _settings;
  29410. private _createInternalTextureOnEvent;
  29411. /**
  29412. * Creates a video texture.
  29413. * If you want to display a video in your scene, this is the special texture for that.
  29414. * This special texture works similar to other textures, with the exception of a few parameters.
  29415. * @see https://doc.babylonjs.com/how_to/video_texture
  29416. * @param name optional name, will detect from video source, if not defined
  29417. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29418. * @param scene is obviously the current scene.
  29419. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29420. * @param invertY is false by default but can be used to invert video on Y axis
  29421. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29422. * @param settings allows finer control over video usage
  29423. */
  29424. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29425. private _getName;
  29426. private _getVideo;
  29427. private _createInternalTexture;
  29428. private reset;
  29429. /**
  29430. * @hidden Internal method to initiate `update`.
  29431. */
  29432. _rebuild(): void;
  29433. /**
  29434. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29435. */
  29436. update(): void;
  29437. /**
  29438. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29439. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29440. */
  29441. updateTexture(isVisible: boolean): void;
  29442. protected _updateInternalTexture: () => void;
  29443. /**
  29444. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29445. * @param url New url.
  29446. */
  29447. updateURL(url: string): void;
  29448. /**
  29449. * Dispose the texture and release its associated resources.
  29450. */
  29451. dispose(): void;
  29452. /**
  29453. * Creates a video texture straight from a stream.
  29454. * @param scene Define the scene the texture should be created in
  29455. * @param stream Define the stream the texture should be created from
  29456. * @returns The created video texture as a promise
  29457. */
  29458. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29459. /**
  29460. * Creates a video texture straight from your WebCam video feed.
  29461. * @param scene Define the scene the texture should be created in
  29462. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29463. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29464. * @returns The created video texture as a promise
  29465. */
  29466. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29467. minWidth: number;
  29468. maxWidth: number;
  29469. minHeight: number;
  29470. maxHeight: number;
  29471. deviceId: string;
  29472. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29473. /**
  29474. * Creates a video texture straight from your WebCam video feed.
  29475. * @param scene Define the scene the texture should be created in
  29476. * @param onReady Define a callback to triggered once the texture will be ready
  29477. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29478. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29479. */
  29480. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29481. minWidth: number;
  29482. maxWidth: number;
  29483. minHeight: number;
  29484. maxHeight: number;
  29485. deviceId: string;
  29486. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29487. }
  29488. }
  29489. declare module BABYLON {
  29490. /**
  29491. * Defines the interface used by objects containing a viewport (like a camera)
  29492. */
  29493. interface IViewportOwnerLike {
  29494. /**
  29495. * Gets or sets the viewport
  29496. */
  29497. viewport: IViewportLike;
  29498. }
  29499. /**
  29500. * Interface for attribute information associated with buffer instanciation
  29501. */
  29502. export class InstancingAttributeInfo {
  29503. /**
  29504. * Index/offset of the attribute in the vertex shader
  29505. */
  29506. index: number;
  29507. /**
  29508. * size of the attribute, 1, 2, 3 or 4
  29509. */
  29510. attributeSize: number;
  29511. /**
  29512. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29513. * default is FLOAT
  29514. */
  29515. attribyteType: number;
  29516. /**
  29517. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29518. */
  29519. normalized: boolean;
  29520. /**
  29521. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29522. */
  29523. offset: number;
  29524. /**
  29525. * Name of the GLSL attribute, for debugging purpose only
  29526. */
  29527. attributeName: string;
  29528. }
  29529. /**
  29530. * Define options used to create a depth texture
  29531. */
  29532. export class DepthTextureCreationOptions {
  29533. /** Specifies whether or not a stencil should be allocated in the texture */
  29534. generateStencil?: boolean;
  29535. /** Specifies whether or not bilinear filtering is enable on the texture */
  29536. bilinearFiltering?: boolean;
  29537. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29538. comparisonFunction?: number;
  29539. /** Specifies if the created texture is a cube texture */
  29540. isCube?: boolean;
  29541. }
  29542. /**
  29543. * Class used to describe the capabilities of the engine relatively to the current browser
  29544. */
  29545. export class EngineCapabilities {
  29546. /** Maximum textures units per fragment shader */
  29547. maxTexturesImageUnits: number;
  29548. /** Maximum texture units per vertex shader */
  29549. maxVertexTextureImageUnits: number;
  29550. /** Maximum textures units in the entire pipeline */
  29551. maxCombinedTexturesImageUnits: number;
  29552. /** Maximum texture size */
  29553. maxTextureSize: number;
  29554. /** Maximum cube texture size */
  29555. maxCubemapTextureSize: number;
  29556. /** Maximum render texture size */
  29557. maxRenderTextureSize: number;
  29558. /** Maximum number of vertex attributes */
  29559. maxVertexAttribs: number;
  29560. /** Maximum number of varyings */
  29561. maxVaryingVectors: number;
  29562. /** Maximum number of uniforms per vertex shader */
  29563. maxVertexUniformVectors: number;
  29564. /** Maximum number of uniforms per fragment shader */
  29565. maxFragmentUniformVectors: number;
  29566. /** Defines if standard derivates (dx/dy) are supported */
  29567. standardDerivatives: boolean;
  29568. /** Defines if s3tc texture compression is supported */
  29569. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29570. /** Defines if pvrtc texture compression is supported */
  29571. pvrtc: any;
  29572. /** Defines if etc1 texture compression is supported */
  29573. etc1: any;
  29574. /** Defines if etc2 texture compression is supported */
  29575. etc2: any;
  29576. /** Defines if astc texture compression is supported */
  29577. astc: any;
  29578. /** Defines if float textures are supported */
  29579. textureFloat: boolean;
  29580. /** Defines if vertex array objects are supported */
  29581. vertexArrayObject: boolean;
  29582. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29583. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29584. /** Gets the maximum level of anisotropy supported */
  29585. maxAnisotropy: number;
  29586. /** Defines if instancing is supported */
  29587. instancedArrays: boolean;
  29588. /** Defines if 32 bits indices are supported */
  29589. uintIndices: boolean;
  29590. /** Defines if high precision shaders are supported */
  29591. highPrecisionShaderSupported: boolean;
  29592. /** Defines if depth reading in the fragment shader is supported */
  29593. fragmentDepthSupported: boolean;
  29594. /** Defines if float texture linear filtering is supported*/
  29595. textureFloatLinearFiltering: boolean;
  29596. /** Defines if rendering to float textures is supported */
  29597. textureFloatRender: boolean;
  29598. /** Defines if half float textures are supported*/
  29599. textureHalfFloat: boolean;
  29600. /** Defines if half float texture linear filtering is supported*/
  29601. textureHalfFloatLinearFiltering: boolean;
  29602. /** Defines if rendering to half float textures is supported */
  29603. textureHalfFloatRender: boolean;
  29604. /** Defines if textureLOD shader command is supported */
  29605. textureLOD: boolean;
  29606. /** Defines if draw buffers extension is supported */
  29607. drawBuffersExtension: boolean;
  29608. /** Defines if depth textures are supported */
  29609. depthTextureExtension: boolean;
  29610. /** Defines if float color buffer are supported */
  29611. colorBufferFloat: boolean;
  29612. /** Gets disjoint timer query extension (null if not supported) */
  29613. timerQuery: EXT_disjoint_timer_query;
  29614. /** Defines if timestamp can be used with timer query */
  29615. canUseTimestampForTimerQuery: boolean;
  29616. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29617. multiview: any;
  29618. /** Function used to let the system compiles shaders in background */
  29619. parallelShaderCompile: {
  29620. COMPLETION_STATUS_KHR: number;
  29621. };
  29622. }
  29623. /** Interface defining initialization parameters for Engine class */
  29624. export interface EngineOptions extends WebGLContextAttributes {
  29625. /**
  29626. * Defines if the engine should no exceed a specified device ratio
  29627. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29628. */
  29629. limitDeviceRatio?: number;
  29630. /**
  29631. * Defines if webvr should be enabled automatically
  29632. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29633. */
  29634. autoEnableWebVR?: boolean;
  29635. /**
  29636. * Defines if webgl2 should be turned off even if supported
  29637. * @see http://doc.babylonjs.com/features/webgl2
  29638. */
  29639. disableWebGL2Support?: boolean;
  29640. /**
  29641. * Defines if webaudio should be initialized as well
  29642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29643. */
  29644. audioEngine?: boolean;
  29645. /**
  29646. * Defines if animations should run using a deterministic lock step
  29647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29648. */
  29649. deterministicLockstep?: boolean;
  29650. /** Defines the maximum steps to use with deterministic lock step mode */
  29651. lockstepMaxSteps?: number;
  29652. /**
  29653. * Defines that engine should ignore context lost events
  29654. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29655. */
  29656. doNotHandleContextLost?: boolean;
  29657. /**
  29658. * Defines that engine should ignore modifying touch action attribute and style
  29659. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29660. */
  29661. doNotHandleTouchAction?: boolean;
  29662. /**
  29663. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29664. */
  29665. useHighPrecisionFloats?: boolean;
  29666. }
  29667. /**
  29668. * Defines the interface used by display changed events
  29669. */
  29670. export interface IDisplayChangedEventArgs {
  29671. /** Gets the vrDisplay object (if any) */
  29672. vrDisplay: Nullable<any>;
  29673. /** Gets a boolean indicating if webVR is supported */
  29674. vrSupported: boolean;
  29675. }
  29676. /**
  29677. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29678. */
  29679. export class Engine {
  29680. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29681. static ExceptionList: ({
  29682. key: string;
  29683. capture: string;
  29684. captureConstraint: number;
  29685. targets: string[];
  29686. } | {
  29687. key: string;
  29688. capture: null;
  29689. captureConstraint: null;
  29690. targets: string[];
  29691. })[];
  29692. /** Gets the list of created engines */
  29693. static readonly Instances: Engine[];
  29694. /**
  29695. * Gets the latest created engine
  29696. */
  29697. static readonly LastCreatedEngine: Nullable<Engine>;
  29698. /**
  29699. * Gets the latest created scene
  29700. */
  29701. static readonly LastCreatedScene: Nullable<Scene>;
  29702. /**
  29703. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29704. * @param flag defines which part of the materials must be marked as dirty
  29705. * @param predicate defines a predicate used to filter which materials should be affected
  29706. */
  29707. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29708. /** @hidden */
  29709. static _TextureLoaders: IInternalTextureLoader[];
  29710. /** Defines that alpha blending is disabled */
  29711. static readonly ALPHA_DISABLE: number;
  29712. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29713. static readonly ALPHA_ADD: number;
  29714. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29715. static readonly ALPHA_COMBINE: number;
  29716. /** Defines that alpha blending to DEST - SRC * DEST */
  29717. static readonly ALPHA_SUBTRACT: number;
  29718. /** Defines that alpha blending to SRC * DEST */
  29719. static readonly ALPHA_MULTIPLY: number;
  29720. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29721. static readonly ALPHA_MAXIMIZED: number;
  29722. /** Defines that alpha blending to SRC + DEST */
  29723. static readonly ALPHA_ONEONE: number;
  29724. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29725. static readonly ALPHA_PREMULTIPLIED: number;
  29726. /**
  29727. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29728. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29729. */
  29730. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29731. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29732. static readonly ALPHA_INTERPOLATE: number;
  29733. /**
  29734. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29735. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29736. */
  29737. static readonly ALPHA_SCREENMODE: number;
  29738. /** Defines that the ressource is not delayed*/
  29739. static readonly DELAYLOADSTATE_NONE: number;
  29740. /** Defines that the ressource was successfully delay loaded */
  29741. static readonly DELAYLOADSTATE_LOADED: number;
  29742. /** Defines that the ressource is currently delay loading */
  29743. static readonly DELAYLOADSTATE_LOADING: number;
  29744. /** Defines that the ressource is delayed and has not started loading */
  29745. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29747. static readonly NEVER: number;
  29748. /** 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 */
  29749. static readonly ALWAYS: number;
  29750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29751. static readonly LESS: number;
  29752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29753. static readonly EQUAL: number;
  29754. /** 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 */
  29755. static readonly LEQUAL: number;
  29756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29757. static readonly GREATER: number;
  29758. /** 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 */
  29759. static readonly GEQUAL: number;
  29760. /** 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 */
  29761. static readonly NOTEQUAL: number;
  29762. /** Passed to stencilOperation to specify that stencil value must be kept */
  29763. static readonly KEEP: number;
  29764. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29765. static readonly REPLACE: number;
  29766. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29767. static readonly INCR: number;
  29768. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29769. static readonly DECR: number;
  29770. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29771. static readonly INVERT: number;
  29772. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29773. static readonly INCR_WRAP: number;
  29774. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29775. static readonly DECR_WRAP: number;
  29776. /** Texture is not repeating outside of 0..1 UVs */
  29777. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29778. /** Texture is repeating outside of 0..1 UVs */
  29779. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29780. /** Texture is repeating and mirrored */
  29781. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29782. /** ALPHA */
  29783. static readonly TEXTUREFORMAT_ALPHA: number;
  29784. /** LUMINANCE */
  29785. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29786. /** LUMINANCE_ALPHA */
  29787. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29788. /** RGB */
  29789. static readonly TEXTUREFORMAT_RGB: number;
  29790. /** RGBA */
  29791. static readonly TEXTUREFORMAT_RGBA: number;
  29792. /** RED */
  29793. static readonly TEXTUREFORMAT_RED: number;
  29794. /** RED (2nd reference) */
  29795. static readonly TEXTUREFORMAT_R: number;
  29796. /** RG */
  29797. static readonly TEXTUREFORMAT_RG: number;
  29798. /** RED_INTEGER */
  29799. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29800. /** RED_INTEGER (2nd reference) */
  29801. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29802. /** RG_INTEGER */
  29803. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29804. /** RGB_INTEGER */
  29805. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29806. /** RGBA_INTEGER */
  29807. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29808. /** UNSIGNED_BYTE */
  29809. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29810. /** UNSIGNED_BYTE (2nd reference) */
  29811. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29812. /** FLOAT */
  29813. static readonly TEXTURETYPE_FLOAT: number;
  29814. /** HALF_FLOAT */
  29815. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29816. /** BYTE */
  29817. static readonly TEXTURETYPE_BYTE: number;
  29818. /** SHORT */
  29819. static readonly TEXTURETYPE_SHORT: number;
  29820. /** UNSIGNED_SHORT */
  29821. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29822. /** INT */
  29823. static readonly TEXTURETYPE_INT: number;
  29824. /** UNSIGNED_INT */
  29825. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29826. /** UNSIGNED_SHORT_4_4_4_4 */
  29827. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29828. /** UNSIGNED_SHORT_5_5_5_1 */
  29829. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29830. /** UNSIGNED_SHORT_5_6_5 */
  29831. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29832. /** UNSIGNED_INT_2_10_10_10_REV */
  29833. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29834. /** UNSIGNED_INT_24_8 */
  29835. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29836. /** UNSIGNED_INT_10F_11F_11F_REV */
  29837. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29838. /** UNSIGNED_INT_5_9_9_9_REV */
  29839. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29840. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29841. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29842. /** nearest is mag = nearest and min = nearest and mip = linear */
  29843. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29844. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29845. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29846. /** Trilinear is mag = linear and min = linear and mip = linear */
  29847. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29848. /** nearest is mag = nearest and min = nearest and mip = linear */
  29849. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29851. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29852. /** Trilinear is mag = linear and min = linear and mip = linear */
  29853. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29854. /** mag = nearest and min = nearest and mip = nearest */
  29855. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29856. /** mag = nearest and min = linear and mip = nearest */
  29857. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29858. /** mag = nearest and min = linear and mip = linear */
  29859. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29860. /** mag = nearest and min = linear and mip = none */
  29861. static readonly TEXTURE_NEAREST_LINEAR: number;
  29862. /** mag = nearest and min = nearest and mip = none */
  29863. static readonly TEXTURE_NEAREST_NEAREST: number;
  29864. /** mag = linear and min = nearest and mip = nearest */
  29865. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29866. /** mag = linear and min = nearest and mip = linear */
  29867. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29868. /** mag = linear and min = linear and mip = none */
  29869. static readonly TEXTURE_LINEAR_LINEAR: number;
  29870. /** mag = linear and min = nearest and mip = none */
  29871. static readonly TEXTURE_LINEAR_NEAREST: number;
  29872. /** Explicit coordinates mode */
  29873. static readonly TEXTURE_EXPLICIT_MODE: number;
  29874. /** Spherical coordinates mode */
  29875. static readonly TEXTURE_SPHERICAL_MODE: number;
  29876. /** Planar coordinates mode */
  29877. static readonly TEXTURE_PLANAR_MODE: number;
  29878. /** Cubic coordinates mode */
  29879. static readonly TEXTURE_CUBIC_MODE: number;
  29880. /** Projection coordinates mode */
  29881. static readonly TEXTURE_PROJECTION_MODE: number;
  29882. /** Skybox coordinates mode */
  29883. static readonly TEXTURE_SKYBOX_MODE: number;
  29884. /** Inverse Cubic coordinates mode */
  29885. static readonly TEXTURE_INVCUBIC_MODE: number;
  29886. /** Equirectangular coordinates mode */
  29887. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29888. /** Equirectangular Fixed coordinates mode */
  29889. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29890. /** Equirectangular Fixed Mirrored coordinates mode */
  29891. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29892. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29893. static readonly SCALEMODE_FLOOR: number;
  29894. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29895. static readonly SCALEMODE_NEAREST: number;
  29896. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29897. static readonly SCALEMODE_CEILING: number;
  29898. /**
  29899. * Returns the current npm package of the sdk
  29900. */
  29901. static readonly NpmPackage: string;
  29902. /**
  29903. * Returns the current version of the framework
  29904. */
  29905. static readonly Version: string;
  29906. /**
  29907. * Returns a string describing the current engine
  29908. */
  29909. readonly description: string;
  29910. /**
  29911. * Gets or sets the epsilon value used by collision engine
  29912. */
  29913. static CollisionsEpsilon: number;
  29914. /**
  29915. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29916. */
  29917. static ShadersRepository: string;
  29918. /**
  29919. * Method called to create the default loading screen.
  29920. * This can be overriden in your own app.
  29921. * @param canvas The rendering canvas element
  29922. * @returns The loading screen
  29923. */
  29924. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29925. /**
  29926. * Method called to create the default rescale post process on each engine.
  29927. */
  29928. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29929. /** @hidden */
  29930. _shaderProcessor: IShaderProcessor;
  29931. /**
  29932. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29933. */
  29934. forcePOTTextures: boolean;
  29935. /**
  29936. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29937. */
  29938. isFullscreen: boolean;
  29939. /**
  29940. * Gets a boolean indicating if the pointer is currently locked
  29941. */
  29942. isPointerLock: boolean;
  29943. /**
  29944. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29945. */
  29946. cullBackFaces: boolean;
  29947. /**
  29948. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29949. */
  29950. renderEvenInBackground: boolean;
  29951. /**
  29952. * Gets or sets a boolean indicating that cache can be kept between frames
  29953. */
  29954. preventCacheWipeBetweenFrames: boolean;
  29955. /**
  29956. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29957. **/
  29958. enableOfflineSupport: boolean;
  29959. /**
  29960. * 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)
  29961. **/
  29962. disableManifestCheck: boolean;
  29963. /**
  29964. * Gets the list of created scenes
  29965. */
  29966. scenes: Scene[];
  29967. /**
  29968. * Event raised when a new scene is created
  29969. */
  29970. onNewSceneAddedObservable: Observable<Scene>;
  29971. /**
  29972. * Gets the list of created postprocesses
  29973. */
  29974. postProcesses: PostProcess[];
  29975. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29976. validateShaderPrograms: boolean;
  29977. /**
  29978. * Observable event triggered each time the rendering canvas is resized
  29979. */
  29980. onResizeObservable: Observable<Engine>;
  29981. /**
  29982. * Observable event triggered each time the canvas loses focus
  29983. */
  29984. onCanvasBlurObservable: Observable<Engine>;
  29985. /**
  29986. * Observable event triggered each time the canvas gains focus
  29987. */
  29988. onCanvasFocusObservable: Observable<Engine>;
  29989. /**
  29990. * Observable event triggered each time the canvas receives pointerout event
  29991. */
  29992. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29993. /**
  29994. * Observable event triggered before each texture is initialized
  29995. */
  29996. onBeforeTextureInitObservable: Observable<Texture>;
  29997. /**
  29998. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29999. */
  30000. disableUniformBuffers: boolean;
  30001. /** @hidden */
  30002. _uniformBuffers: UniformBuffer[];
  30003. /**
  30004. * Gets a boolean indicating that the engine supports uniform buffers
  30005. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30006. */
  30007. readonly supportsUniformBuffers: boolean;
  30008. /**
  30009. * Observable raised when the engine begins a new frame
  30010. */
  30011. onBeginFrameObservable: Observable<Engine>;
  30012. /**
  30013. * If set, will be used to request the next animation frame for the render loop
  30014. */
  30015. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30016. /**
  30017. * Observable raised when the engine ends the current frame
  30018. */
  30019. onEndFrameObservable: Observable<Engine>;
  30020. /**
  30021. * Observable raised when the engine is about to compile a shader
  30022. */
  30023. onBeforeShaderCompilationObservable: Observable<Engine>;
  30024. /**
  30025. * Observable raised when the engine has jsut compiled a shader
  30026. */
  30027. onAfterShaderCompilationObservable: Observable<Engine>;
  30028. /** @hidden */
  30029. _gl: WebGLRenderingContext;
  30030. private _renderingCanvas;
  30031. private _windowIsBackground;
  30032. private _webGLVersion;
  30033. protected _highPrecisionShadersAllowed: boolean;
  30034. /** @hidden */
  30035. readonly _shouldUseHighPrecisionShader: boolean;
  30036. /**
  30037. * Gets a boolean indicating that only power of 2 textures are supported
  30038. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30039. */
  30040. readonly needPOTTextures: boolean;
  30041. /** @hidden */
  30042. _badOS: boolean;
  30043. /** @hidden */
  30044. _badDesktopOS: boolean;
  30045. /**
  30046. * Gets the audio engine
  30047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30048. * @ignorenaming
  30049. */
  30050. static audioEngine: IAudioEngine;
  30051. /**
  30052. * Default AudioEngine factory responsible of creating the Audio Engine.
  30053. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30054. */
  30055. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30056. /**
  30057. * Default offline support factory responsible of creating a tool used to store data locally.
  30058. * By default, this will create a Database object if the workload has been embedded.
  30059. */
  30060. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30061. private _onFocus;
  30062. private _onBlur;
  30063. private _onCanvasPointerOut;
  30064. private _onCanvasBlur;
  30065. private _onCanvasFocus;
  30066. private _onFullscreenChange;
  30067. private _onPointerLockChange;
  30068. private _hardwareScalingLevel;
  30069. /** @hidden */
  30070. _caps: EngineCapabilities;
  30071. private _pointerLockRequested;
  30072. private _isStencilEnable;
  30073. private _colorWrite;
  30074. private _loadingScreen;
  30075. /** @hidden */
  30076. _drawCalls: PerfCounter;
  30077. private _glVersion;
  30078. private _glRenderer;
  30079. private _glVendor;
  30080. private _videoTextureSupported;
  30081. private _renderingQueueLaunched;
  30082. private _activeRenderLoops;
  30083. private _deterministicLockstep;
  30084. private _lockstepMaxSteps;
  30085. /**
  30086. * Observable signaled when a context lost event is raised
  30087. */
  30088. onContextLostObservable: Observable<Engine>;
  30089. /**
  30090. * Observable signaled when a context restored event is raised
  30091. */
  30092. onContextRestoredObservable: Observable<Engine>;
  30093. private _onContextLost;
  30094. private _onContextRestored;
  30095. private _contextWasLost;
  30096. /** @hidden */
  30097. _doNotHandleContextLost: boolean;
  30098. /**
  30099. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30101. */
  30102. doNotHandleContextLost: boolean;
  30103. private _performanceMonitor;
  30104. private _fps;
  30105. private _deltaTime;
  30106. /**
  30107. * Turn this value on if you want to pause FPS computation when in background
  30108. */
  30109. disablePerformanceMonitorInBackground: boolean;
  30110. /**
  30111. * Gets the performance monitor attached to this engine
  30112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30113. */
  30114. readonly performanceMonitor: PerformanceMonitor;
  30115. /**
  30116. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30117. */
  30118. disableVertexArrayObjects: boolean;
  30119. /** @hidden */
  30120. protected _depthCullingState: _DepthCullingState;
  30121. /** @hidden */
  30122. protected _stencilState: _StencilState;
  30123. /** @hidden */
  30124. protected _alphaState: _AlphaState;
  30125. /** @hidden */
  30126. protected _alphaMode: number;
  30127. /** @hidden */
  30128. _internalTexturesCache: InternalTexture[];
  30129. /** @hidden */
  30130. protected _activeChannel: number;
  30131. private _currentTextureChannel;
  30132. /** @hidden */
  30133. protected _boundTexturesCache: {
  30134. [key: string]: Nullable<InternalTexture>;
  30135. };
  30136. /** @hidden */
  30137. protected _currentEffect: Nullable<Effect>;
  30138. /** @hidden */
  30139. protected _currentProgram: Nullable<WebGLProgram>;
  30140. private _compiledEffects;
  30141. private _vertexAttribArraysEnabled;
  30142. /** @hidden */
  30143. protected _cachedViewport: Nullable<IViewportLike>;
  30144. private _cachedVertexArrayObject;
  30145. /** @hidden */
  30146. protected _cachedVertexBuffers: any;
  30147. /** @hidden */
  30148. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30149. /** @hidden */
  30150. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30151. /** @hidden */
  30152. _currentRenderTarget: Nullable<InternalTexture>;
  30153. private _uintIndicesCurrentlySet;
  30154. private _currentBoundBuffer;
  30155. /** @hidden */
  30156. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30157. private _currentBufferPointers;
  30158. private _currentInstanceLocations;
  30159. private _currentInstanceBuffers;
  30160. private _textureUnits;
  30161. /** @hidden */
  30162. _workingCanvas: Nullable<HTMLCanvasElement>;
  30163. /** @hidden */
  30164. _workingContext: Nullable<CanvasRenderingContext2D>;
  30165. private _rescalePostProcess;
  30166. private _dummyFramebuffer;
  30167. private _externalData;
  30168. /** @hidden */
  30169. _bindedRenderFunction: any;
  30170. private _vaoRecordInProgress;
  30171. private _mustWipeVertexAttributes;
  30172. private _emptyTexture;
  30173. private _emptyCubeTexture;
  30174. private _emptyTexture3D;
  30175. /** @hidden */
  30176. _frameHandler: number;
  30177. private _nextFreeTextureSlots;
  30178. private _maxSimultaneousTextures;
  30179. private _activeRequests;
  30180. private _texturesSupported;
  30181. /** @hidden */
  30182. _textureFormatInUse: Nullable<string>;
  30183. /**
  30184. * Gets the list of texture formats supported
  30185. */
  30186. readonly texturesSupported: Array<string>;
  30187. /**
  30188. * Gets the list of texture formats in use
  30189. */
  30190. readonly textureFormatInUse: Nullable<string>;
  30191. /**
  30192. * Gets the current viewport
  30193. */
  30194. readonly currentViewport: Nullable<IViewportLike>;
  30195. /**
  30196. * Gets the default empty texture
  30197. */
  30198. readonly emptyTexture: InternalTexture;
  30199. /**
  30200. * Gets the default empty 3D texture
  30201. */
  30202. readonly emptyTexture3D: InternalTexture;
  30203. /**
  30204. * Gets the default empty cube texture
  30205. */
  30206. readonly emptyCubeTexture: InternalTexture;
  30207. /**
  30208. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30209. */
  30210. readonly premultipliedAlpha: boolean;
  30211. /**
  30212. * Creates a new engine
  30213. * @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
  30214. * @param antialias defines enable antialiasing (default: false)
  30215. * @param options defines further options to be sent to the getContext() function
  30216. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30217. */
  30218. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30219. /**
  30220. * Initializes a webVR display and starts listening to display change events
  30221. * The onVRDisplayChangedObservable will be notified upon these changes
  30222. * @returns The onVRDisplayChangedObservable
  30223. */
  30224. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30225. /** @hidden */
  30226. _prepareVRComponent(): void;
  30227. /** @hidden */
  30228. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30229. /** @hidden */
  30230. _submitVRFrame(): void;
  30231. /**
  30232. * Call this function to leave webVR mode
  30233. * Will do nothing if webVR is not supported or if there is no webVR device
  30234. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30235. */
  30236. disableVR(): void;
  30237. /**
  30238. * Gets a boolean indicating that the system is in VR mode and is presenting
  30239. * @returns true if VR mode is engaged
  30240. */
  30241. isVRPresenting(): boolean;
  30242. /** @hidden */
  30243. _requestVRFrame(): void;
  30244. private _disableTouchAction;
  30245. private _rebuildInternalTextures;
  30246. private _rebuildEffects;
  30247. /**
  30248. * Gets a boolean indicating if all created effects are ready
  30249. * @returns true if all effects are ready
  30250. */
  30251. areAllEffectsReady(): boolean;
  30252. private _rebuildBuffers;
  30253. private _initGLContext;
  30254. /**
  30255. * Gets version of the current webGL context
  30256. */
  30257. readonly webGLVersion: number;
  30258. /**
  30259. * Gets a string idenfifying the name of the class
  30260. * @returns "Engine" string
  30261. */
  30262. getClassName(): string;
  30263. /**
  30264. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30265. */
  30266. readonly isStencilEnable: boolean;
  30267. /** @hidden */
  30268. _prepareWorkingCanvas(): void;
  30269. /**
  30270. * Reset the texture cache to empty state
  30271. */
  30272. resetTextureCache(): void;
  30273. /**
  30274. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30275. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30276. * @returns true if engine is in deterministic lock step mode
  30277. */
  30278. isDeterministicLockStep(): boolean;
  30279. /**
  30280. * Gets the max steps when engine is running in deterministic lock step
  30281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30282. * @returns the max steps
  30283. */
  30284. getLockstepMaxSteps(): number;
  30285. /**
  30286. * Gets an object containing information about the current webGL context
  30287. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30288. */
  30289. getGlInfo(): {
  30290. vendor: string;
  30291. renderer: string;
  30292. version: string;
  30293. };
  30294. /**
  30295. * Gets current aspect ratio
  30296. * @param viewportOwner defines the camera to use to get the aspect ratio
  30297. * @param useScreen defines if screen size must be used (or the current render target if any)
  30298. * @returns a number defining the aspect ratio
  30299. */
  30300. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30301. /**
  30302. * Gets current screen aspect ratio
  30303. * @returns a number defining the aspect ratio
  30304. */
  30305. getScreenAspectRatio(): number;
  30306. /**
  30307. * Gets the current render width
  30308. * @param useScreen defines if screen size must be used (or the current render target if any)
  30309. * @returns a number defining the current render width
  30310. */
  30311. getRenderWidth(useScreen?: boolean): number;
  30312. /**
  30313. * Gets the current render height
  30314. * @param useScreen defines if screen size must be used (or the current render target if any)
  30315. * @returns a number defining the current render height
  30316. */
  30317. getRenderHeight(useScreen?: boolean): number;
  30318. /**
  30319. * Gets the HTML canvas attached with the current webGL context
  30320. * @returns a HTML canvas
  30321. */
  30322. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30323. /**
  30324. * Gets the client rect of the HTML canvas attached with the current webGL context
  30325. * @returns a client rectanglee
  30326. */
  30327. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30328. /**
  30329. * Defines the hardware scaling level.
  30330. * By default the hardware scaling level is computed from the window device ratio.
  30331. * 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.
  30332. * @param level defines the level to use
  30333. */
  30334. setHardwareScalingLevel(level: number): void;
  30335. /**
  30336. * Gets the current hardware scaling level.
  30337. * By default the hardware scaling level is computed from the window device ratio.
  30338. * 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.
  30339. * @returns a number indicating the current hardware scaling level
  30340. */
  30341. getHardwareScalingLevel(): number;
  30342. /**
  30343. * Gets the list of loaded textures
  30344. * @returns an array containing all loaded textures
  30345. */
  30346. getLoadedTexturesCache(): InternalTexture[];
  30347. /**
  30348. * Gets the object containing all engine capabilities
  30349. * @returns the EngineCapabilities object
  30350. */
  30351. getCaps(): EngineCapabilities;
  30352. /**
  30353. * Gets the current depth function
  30354. * @returns a number defining the depth function
  30355. */
  30356. getDepthFunction(): Nullable<number>;
  30357. /**
  30358. * Sets the current depth function
  30359. * @param depthFunc defines the function to use
  30360. */
  30361. setDepthFunction(depthFunc: number): void;
  30362. /**
  30363. * Sets the current depth function to GREATER
  30364. */
  30365. setDepthFunctionToGreater(): void;
  30366. /**
  30367. * Sets the current depth function to GEQUAL
  30368. */
  30369. setDepthFunctionToGreaterOrEqual(): void;
  30370. /**
  30371. * Sets the current depth function to LESS
  30372. */
  30373. setDepthFunctionToLess(): void;
  30374. private _cachedStencilBuffer;
  30375. private _cachedStencilFunction;
  30376. private _cachedStencilMask;
  30377. private _cachedStencilOperationPass;
  30378. private _cachedStencilOperationFail;
  30379. private _cachedStencilOperationDepthFail;
  30380. private _cachedStencilReference;
  30381. /**
  30382. * Caches the the state of the stencil buffer
  30383. */
  30384. cacheStencilState(): void;
  30385. /**
  30386. * Restores the state of the stencil buffer
  30387. */
  30388. restoreStencilState(): void;
  30389. /**
  30390. * Sets the current depth function to LEQUAL
  30391. */
  30392. setDepthFunctionToLessOrEqual(): void;
  30393. /**
  30394. * Gets a boolean indicating if stencil buffer is enabled
  30395. * @returns the current stencil buffer state
  30396. */
  30397. getStencilBuffer(): boolean;
  30398. /**
  30399. * Enable or disable the stencil buffer
  30400. * @param enable defines if the stencil buffer must be enabled or disabled
  30401. */
  30402. setStencilBuffer(enable: boolean): void;
  30403. /**
  30404. * Gets the current stencil mask
  30405. * @returns a number defining the new stencil mask to use
  30406. */
  30407. getStencilMask(): number;
  30408. /**
  30409. * Sets the current stencil mask
  30410. * @param mask defines the new stencil mask to use
  30411. */
  30412. setStencilMask(mask: number): void;
  30413. /**
  30414. * Gets the current stencil function
  30415. * @returns a number defining the stencil function to use
  30416. */
  30417. getStencilFunction(): number;
  30418. /**
  30419. * Gets the current stencil reference value
  30420. * @returns a number defining the stencil reference value to use
  30421. */
  30422. getStencilFunctionReference(): number;
  30423. /**
  30424. * Gets the current stencil mask
  30425. * @returns a number defining the stencil mask to use
  30426. */
  30427. getStencilFunctionMask(): number;
  30428. /**
  30429. * Sets the current stencil function
  30430. * @param stencilFunc defines the new stencil function to use
  30431. */
  30432. setStencilFunction(stencilFunc: number): void;
  30433. /**
  30434. * Sets the current stencil reference
  30435. * @param reference defines the new stencil reference to use
  30436. */
  30437. setStencilFunctionReference(reference: number): void;
  30438. /**
  30439. * Sets the current stencil mask
  30440. * @param mask defines the new stencil mask to use
  30441. */
  30442. setStencilFunctionMask(mask: number): void;
  30443. /**
  30444. * Gets the current stencil operation when stencil fails
  30445. * @returns a number defining stencil operation to use when stencil fails
  30446. */
  30447. getStencilOperationFail(): number;
  30448. /**
  30449. * Gets the current stencil operation when depth fails
  30450. * @returns a number defining stencil operation to use when depth fails
  30451. */
  30452. getStencilOperationDepthFail(): number;
  30453. /**
  30454. * Gets the current stencil operation when stencil passes
  30455. * @returns a number defining stencil operation to use when stencil passes
  30456. */
  30457. getStencilOperationPass(): number;
  30458. /**
  30459. * Sets the stencil operation to use when stencil fails
  30460. * @param operation defines the stencil operation to use when stencil fails
  30461. */
  30462. setStencilOperationFail(operation: number): void;
  30463. /**
  30464. * Sets the stencil operation to use when depth fails
  30465. * @param operation defines the stencil operation to use when depth fails
  30466. */
  30467. setStencilOperationDepthFail(operation: number): void;
  30468. /**
  30469. * Sets the stencil operation to use when stencil passes
  30470. * @param operation defines the stencil operation to use when stencil passes
  30471. */
  30472. setStencilOperationPass(operation: number): void;
  30473. /**
  30474. * Sets a boolean indicating if the dithering state is enabled or disabled
  30475. * @param value defines the dithering state
  30476. */
  30477. setDitheringState(value: boolean): void;
  30478. /**
  30479. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30480. * @param value defines the rasterizer state
  30481. */
  30482. setRasterizerState(value: boolean): void;
  30483. /**
  30484. * stop executing a render loop function and remove it from the execution array
  30485. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30486. */
  30487. stopRenderLoop(renderFunction?: () => void): void;
  30488. /** @hidden */
  30489. _renderLoop(): void;
  30490. /**
  30491. * Register and execute a render loop. The engine can have more than one render function
  30492. * @param renderFunction defines the function to continuously execute
  30493. */
  30494. runRenderLoop(renderFunction: () => void): void;
  30495. /**
  30496. * Toggle full screen mode
  30497. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30498. */
  30499. switchFullscreen(requestPointerLock: boolean): void;
  30500. /**
  30501. * Enters full screen mode
  30502. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30503. */
  30504. enterFullscreen(requestPointerLock: boolean): void;
  30505. /**
  30506. * Exits full screen mode
  30507. */
  30508. exitFullscreen(): void;
  30509. /**
  30510. * Enters Pointerlock mode
  30511. */
  30512. enterPointerlock(): void;
  30513. /**
  30514. * Exits Pointerlock mode
  30515. */
  30516. exitPointerlock(): void;
  30517. /**
  30518. * Clear the current render buffer or the current render target (if any is set up)
  30519. * @param color defines the color to use
  30520. * @param backBuffer defines if the back buffer must be cleared
  30521. * @param depth defines if the depth buffer must be cleared
  30522. * @param stencil defines if the stencil buffer must be cleared
  30523. */
  30524. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30525. /**
  30526. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30527. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30528. * @param y defines the y-coordinate of the corner of the clear rectangle
  30529. * @param width defines the width of the clear rectangle
  30530. * @param height defines the height of the clear rectangle
  30531. * @param clearColor defines the clear color
  30532. */
  30533. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30534. /**
  30535. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30536. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30537. * @param y defines the y-coordinate of the corner of the clear rectangle
  30538. * @param width defines the width of the clear rectangle
  30539. * @param height defines the height of the clear rectangle
  30540. */
  30541. enableScissor(x: number, y: number, width: number, height: number): void;
  30542. /**
  30543. * Disable previously set scissor test rectangle
  30544. */
  30545. disableScissor(): void;
  30546. private _viewportCached;
  30547. /** @hidden */
  30548. _viewport(x: number, y: number, width: number, height: number): void;
  30549. /**
  30550. * Set the WebGL's viewport
  30551. * @param viewport defines the viewport element to be used
  30552. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30553. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30554. */
  30555. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30556. /**
  30557. * Directly set the WebGL Viewport
  30558. * @param x defines the x coordinate of the viewport (in screen space)
  30559. * @param y defines the y coordinate of the viewport (in screen space)
  30560. * @param width defines the width of the viewport (in screen space)
  30561. * @param height defines the height of the viewport (in screen space)
  30562. * @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
  30563. */
  30564. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30565. /**
  30566. * Begin a new frame
  30567. */
  30568. beginFrame(): void;
  30569. /**
  30570. * Enf the current frame
  30571. */
  30572. endFrame(): void;
  30573. /**
  30574. * Resize the view according to the canvas' size
  30575. */
  30576. resize(): void;
  30577. /**
  30578. * Force a specific size of the canvas
  30579. * @param width defines the new canvas' width
  30580. * @param height defines the new canvas' height
  30581. */
  30582. setSize(width: number, height: number): void;
  30583. /**
  30584. * Binds the frame buffer to the specified texture.
  30585. * @param texture The texture to render to or null for the default canvas
  30586. * @param faceIndex The face of the texture to render to in case of cube texture
  30587. * @param requiredWidth The width of the target to render to
  30588. * @param requiredHeight The height of the target to render to
  30589. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30590. * @param depthStencilTexture The depth stencil texture to use to render
  30591. * @param lodLevel defines le lod level to bind to the frame buffer
  30592. */
  30593. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30594. /** @hidden */
  30595. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30596. /**
  30597. * Unbind the current render target texture from the webGL context
  30598. * @param texture defines the render target texture to unbind
  30599. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30600. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30601. */
  30602. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30603. /**
  30604. * Force the mipmap generation for the given render target texture
  30605. * @param texture defines the render target texture to use
  30606. */
  30607. generateMipMapsForCubemap(texture: InternalTexture): void;
  30608. /**
  30609. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30610. */
  30611. flushFramebuffer(): void;
  30612. /**
  30613. * Unbind the current render target and bind the default framebuffer
  30614. */
  30615. restoreDefaultFramebuffer(): void;
  30616. /**
  30617. * Create an uniform buffer
  30618. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30619. * @param elements defines the content of the uniform buffer
  30620. * @returns the webGL uniform buffer
  30621. */
  30622. createUniformBuffer(elements: FloatArray): DataBuffer;
  30623. /**
  30624. * Create a dynamic uniform buffer
  30625. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30626. * @param elements defines the content of the uniform buffer
  30627. * @returns the webGL uniform buffer
  30628. */
  30629. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30630. /**
  30631. * Update an existing uniform buffer
  30632. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30633. * @param uniformBuffer defines the target uniform buffer
  30634. * @param elements defines the content to update
  30635. * @param offset defines the offset in the uniform buffer where update should start
  30636. * @param count defines the size of the data to update
  30637. */
  30638. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30639. private _resetVertexBufferBinding;
  30640. /**
  30641. * Creates a vertex buffer
  30642. * @param data the data for the vertex buffer
  30643. * @returns the new WebGL static buffer
  30644. */
  30645. createVertexBuffer(data: DataArray): DataBuffer;
  30646. /**
  30647. * Creates a dynamic vertex buffer
  30648. * @param data the data for the dynamic vertex buffer
  30649. * @returns the new WebGL dynamic buffer
  30650. */
  30651. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30652. /**
  30653. * Update a dynamic index buffer
  30654. * @param indexBuffer defines the target index buffer
  30655. * @param indices defines the data to update
  30656. * @param offset defines the offset in the target index buffer where update should start
  30657. */
  30658. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30659. /**
  30660. * Updates a dynamic vertex buffer.
  30661. * @param vertexBuffer the vertex buffer to update
  30662. * @param data the data used to update the vertex buffer
  30663. * @param byteOffset the byte offset of the data
  30664. * @param byteLength the byte length of the data
  30665. */
  30666. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30667. private _resetIndexBufferBinding;
  30668. /**
  30669. * Creates a new index buffer
  30670. * @param indices defines the content of the index buffer
  30671. * @param updatable defines if the index buffer must be updatable
  30672. * @returns a new webGL buffer
  30673. */
  30674. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30675. /**
  30676. * Bind a webGL buffer to the webGL context
  30677. * @param buffer defines the buffer to bind
  30678. */
  30679. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30680. /**
  30681. * Bind an uniform buffer to the current webGL context
  30682. * @param buffer defines the buffer to bind
  30683. */
  30684. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30685. /**
  30686. * Bind a buffer to the current webGL context at a given location
  30687. * @param buffer defines the buffer to bind
  30688. * @param location defines the index where to bind the buffer
  30689. */
  30690. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30691. /**
  30692. * Bind a specific block at a given index in a specific shader program
  30693. * @param pipelineContext defines the pipeline context to use
  30694. * @param blockName defines the block name
  30695. * @param index defines the index where to bind the block
  30696. */
  30697. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30698. private bindIndexBuffer;
  30699. private bindBuffer;
  30700. /**
  30701. * update the bound buffer with the given data
  30702. * @param data defines the data to update
  30703. */
  30704. updateArrayBuffer(data: Float32Array): void;
  30705. private _vertexAttribPointer;
  30706. private _bindIndexBufferWithCache;
  30707. private _bindVertexBuffersAttributes;
  30708. /**
  30709. * Records a vertex array object
  30710. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30711. * @param vertexBuffers defines the list of vertex buffers to store
  30712. * @param indexBuffer defines the index buffer to store
  30713. * @param effect defines the effect to store
  30714. * @returns the new vertex array object
  30715. */
  30716. recordVertexArrayObject(vertexBuffers: {
  30717. [key: string]: VertexBuffer;
  30718. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30719. /**
  30720. * Bind a specific vertex array object
  30721. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30722. * @param vertexArrayObject defines the vertex array object to bind
  30723. * @param indexBuffer defines the index buffer to bind
  30724. */
  30725. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30726. /**
  30727. * Bind webGl buffers directly to the webGL context
  30728. * @param vertexBuffer defines the vertex buffer to bind
  30729. * @param indexBuffer defines the index buffer to bind
  30730. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30731. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30732. * @param effect defines the effect associated with the vertex buffer
  30733. */
  30734. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30735. private _unbindVertexArrayObject;
  30736. /**
  30737. * Bind a list of vertex buffers to the webGL context
  30738. * @param vertexBuffers defines the list of vertex buffers to bind
  30739. * @param indexBuffer defines the index buffer to bind
  30740. * @param effect defines the effect associated with the vertex buffers
  30741. */
  30742. bindBuffers(vertexBuffers: {
  30743. [key: string]: Nullable<VertexBuffer>;
  30744. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30745. /**
  30746. * Unbind all instance attributes
  30747. */
  30748. unbindInstanceAttributes(): void;
  30749. /**
  30750. * Release and free the memory of a vertex array object
  30751. * @param vao defines the vertex array object to delete
  30752. */
  30753. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30754. /** @hidden */
  30755. _releaseBuffer(buffer: DataBuffer): boolean;
  30756. /**
  30757. * Creates a webGL buffer to use with instanciation
  30758. * @param capacity defines the size of the buffer
  30759. * @returns the webGL buffer
  30760. */
  30761. createInstancesBuffer(capacity: number): DataBuffer;
  30762. /**
  30763. * Delete a webGL buffer used with instanciation
  30764. * @param buffer defines the webGL buffer to delete
  30765. */
  30766. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30767. /**
  30768. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30769. * @param instancesBuffer defines the webGL buffer to update and bind
  30770. * @param data defines the data to store in the buffer
  30771. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30772. */
  30773. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30774. /**
  30775. * Apply all cached states (depth, culling, stencil and alpha)
  30776. */
  30777. applyStates(): void;
  30778. /**
  30779. * Send a draw order
  30780. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30781. * @param indexStart defines the starting index
  30782. * @param indexCount defines the number of index to draw
  30783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30784. */
  30785. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30786. /**
  30787. * Draw a list of points
  30788. * @param verticesStart defines the index of first vertex to draw
  30789. * @param verticesCount defines the count of vertices to draw
  30790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30791. */
  30792. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30793. /**
  30794. * Draw a list of unindexed primitives
  30795. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30796. * @param verticesStart defines the index of first vertex to draw
  30797. * @param verticesCount defines the count of vertices to draw
  30798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30799. */
  30800. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30801. /**
  30802. * Draw a list of indexed primitives
  30803. * @param fillMode defines the primitive to use
  30804. * @param indexStart defines the starting index
  30805. * @param indexCount defines the number of index to draw
  30806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30807. */
  30808. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30809. /**
  30810. * Draw a list of unindexed primitives
  30811. * @param fillMode defines the primitive to use
  30812. * @param verticesStart defines the index of first vertex to draw
  30813. * @param verticesCount defines the count of vertices to draw
  30814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30815. */
  30816. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30817. private _drawMode;
  30818. /** @hidden */
  30819. _releaseEffect(effect: Effect): void;
  30820. /** @hidden */
  30821. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30822. /**
  30823. * Create a new effect (used to store vertex/fragment shaders)
  30824. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30825. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30826. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30827. * @param samplers defines an array of string used to represent textures
  30828. * @param defines defines the string containing the defines to use to compile the shaders
  30829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30830. * @param onCompiled defines a function to call when the effect creation is successful
  30831. * @param onError defines a function to call when the effect creation has failed
  30832. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30833. * @returns the new Effect
  30834. */
  30835. 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;
  30836. private _compileShader;
  30837. private _compileRawShader;
  30838. /**
  30839. * Directly creates a webGL program
  30840. * @param pipelineContext defines the pipeline context to attach to
  30841. * @param vertexCode defines the vertex shader code to use
  30842. * @param fragmentCode defines the fragment shader code to use
  30843. * @param context defines the webGL context to use (if not set, the current one will be used)
  30844. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30845. * @returns the new webGL program
  30846. */
  30847. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30848. /**
  30849. * Creates a webGL program
  30850. * @param pipelineContext defines the pipeline context to attach to
  30851. * @param vertexCode defines the vertex shader code to use
  30852. * @param fragmentCode defines the fragment shader code to use
  30853. * @param defines defines the string containing the defines to use to compile the shaders
  30854. * @param context defines the webGL context to use (if not set, the current one will be used)
  30855. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30856. * @returns the new webGL program
  30857. */
  30858. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30859. /**
  30860. * Creates a new pipeline context
  30861. * @returns the new pipeline
  30862. */
  30863. createPipelineContext(): WebGLPipelineContext;
  30864. private _createShaderProgram;
  30865. private _finalizePipelineContext;
  30866. /** @hidden */
  30867. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30868. /** @hidden */
  30869. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30870. /** @hidden */
  30871. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30872. /**
  30873. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30874. * @param pipelineContext defines the pipeline context to use
  30875. * @param uniformsNames defines the list of uniform names
  30876. * @returns an array of webGL uniform locations
  30877. */
  30878. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30879. /**
  30880. * Gets the lsit of active attributes for a given webGL program
  30881. * @param pipelineContext defines the pipeline context to use
  30882. * @param attributesNames defines the list of attribute names to get
  30883. * @returns an array of indices indicating the offset of each attribute
  30884. */
  30885. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30886. /**
  30887. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30888. * @param effect defines the effect to activate
  30889. */
  30890. enableEffect(effect: Nullable<Effect>): void;
  30891. /**
  30892. * Set the value of an uniform to an array of int32
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of int32 to store
  30895. */
  30896. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of int32 (stored as vec2)
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param array defines the array of int32 to store
  30901. */
  30902. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30903. /**
  30904. * Set the value of an uniform to an array of int32 (stored as vec3)
  30905. * @param uniform defines the webGL uniform location where to store the value
  30906. * @param array defines the array of int32 to store
  30907. */
  30908. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30909. /**
  30910. * Set the value of an uniform to an array of int32 (stored as vec4)
  30911. * @param uniform defines the webGL uniform location where to store the value
  30912. * @param array defines the array of int32 to store
  30913. */
  30914. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30915. /**
  30916. * Set the value of an uniform to an array of float32
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param array defines the array of float32 to store
  30919. */
  30920. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30921. /**
  30922. * Set the value of an uniform to an array of float32 (stored as vec2)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param array defines the array of float32 to store
  30925. */
  30926. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to an array of float32 (stored as vec3)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param array defines the array of float32 to store
  30931. */
  30932. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to an array of float32 (stored as vec4)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param array defines the array of float32 to store
  30937. */
  30938. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30939. /**
  30940. * Set the value of an uniform to an array of number
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param array defines the array of number to store
  30943. */
  30944. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30945. /**
  30946. * Set the value of an uniform to an array of number (stored as vec2)
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param array defines the array of number to store
  30949. */
  30950. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30951. /**
  30952. * Set the value of an uniform to an array of number (stored as vec3)
  30953. * @param uniform defines the webGL uniform location where to store the value
  30954. * @param array defines the array of number to store
  30955. */
  30956. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30957. /**
  30958. * Set the value of an uniform to an array of number (stored as vec4)
  30959. * @param uniform defines the webGL uniform location where to store the value
  30960. * @param array defines the array of number to store
  30961. */
  30962. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30963. /**
  30964. * Set the value of an uniform to an array of float32 (stored as matrices)
  30965. * @param uniform defines the webGL uniform location where to store the value
  30966. * @param matrices defines the array of float32 to store
  30967. */
  30968. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30969. /**
  30970. * Set the value of an uniform to a matrix (3x3)
  30971. * @param uniform defines the webGL uniform location where to store the value
  30972. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30973. */
  30974. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30975. /**
  30976. * Set the value of an uniform to a matrix (2x2)
  30977. * @param uniform defines the webGL uniform location where to store the value
  30978. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30979. */
  30980. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30981. /**
  30982. * Set the value of an uniform to a number (int)
  30983. * @param uniform defines the webGL uniform location where to store the value
  30984. * @param value defines the int number to store
  30985. */
  30986. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30987. /**
  30988. * Set the value of an uniform to a number (float)
  30989. * @param uniform defines the webGL uniform location where to store the value
  30990. * @param value defines the float number to store
  30991. */
  30992. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30993. /**
  30994. * Set the value of an uniform to a vec2
  30995. * @param uniform defines the webGL uniform location where to store the value
  30996. * @param x defines the 1st component of the value
  30997. * @param y defines the 2nd component of the value
  30998. */
  30999. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31000. /**
  31001. * Set the value of an uniform to a vec3
  31002. * @param uniform defines the webGL uniform location where to store the value
  31003. * @param x defines the 1st component of the value
  31004. * @param y defines the 2nd component of the value
  31005. * @param z defines the 3rd component of the value
  31006. */
  31007. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31008. /**
  31009. * Set the value of an uniform to a boolean
  31010. * @param uniform defines the webGL uniform location where to store the value
  31011. * @param bool defines the boolean to store
  31012. */
  31013. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31014. /**
  31015. * Set the value of an uniform to a vec4
  31016. * @param uniform defines the webGL uniform location where to store the value
  31017. * @param x defines the 1st component of the value
  31018. * @param y defines the 2nd component of the value
  31019. * @param z defines the 3rd component of the value
  31020. * @param w defines the 4th component of the value
  31021. */
  31022. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31023. /**
  31024. * Sets a Color4 on a uniform variable
  31025. * @param uniform defines the uniform location
  31026. * @param color4 defines the value to be set
  31027. */
  31028. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31029. /**
  31030. * Set various states to the webGL context
  31031. * @param culling defines backface culling state
  31032. * @param zOffset defines the value to apply to zOffset (0 by default)
  31033. * @param force defines if states must be applied even if cache is up to date
  31034. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31035. */
  31036. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31037. /**
  31038. * Set the z offset to apply to current rendering
  31039. * @param value defines the offset to apply
  31040. */
  31041. setZOffset(value: number): void;
  31042. /**
  31043. * Gets the current value of the zOffset
  31044. * @returns the current zOffset state
  31045. */
  31046. getZOffset(): number;
  31047. /**
  31048. * Enable or disable depth buffering
  31049. * @param enable defines the state to set
  31050. */
  31051. setDepthBuffer(enable: boolean): void;
  31052. /**
  31053. * Gets a boolean indicating if depth writing is enabled
  31054. * @returns the current depth writing state
  31055. */
  31056. getDepthWrite(): boolean;
  31057. /**
  31058. * Enable or disable depth writing
  31059. * @param enable defines the state to set
  31060. */
  31061. setDepthWrite(enable: boolean): void;
  31062. /**
  31063. * Enable or disable color writing
  31064. * @param enable defines the state to set
  31065. */
  31066. setColorWrite(enable: boolean): void;
  31067. /**
  31068. * Gets a boolean indicating if color writing is enabled
  31069. * @returns the current color writing state
  31070. */
  31071. getColorWrite(): boolean;
  31072. /**
  31073. * Sets alpha constants used by some alpha blending modes
  31074. * @param r defines the red component
  31075. * @param g defines the green component
  31076. * @param b defines the blue component
  31077. * @param a defines the alpha component
  31078. */
  31079. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31080. /**
  31081. * Sets the current alpha mode
  31082. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31083. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31084. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31085. */
  31086. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31087. /**
  31088. * Gets the current alpha mode
  31089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31090. * @returns the current alpha mode
  31091. */
  31092. getAlphaMode(): number;
  31093. /**
  31094. * Clears the list of texture accessible through engine.
  31095. * This can help preventing texture load conflict due to name collision.
  31096. */
  31097. clearInternalTexturesCache(): void;
  31098. /**
  31099. * Force the entire cache to be cleared
  31100. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31101. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31102. */
  31103. wipeCaches(bruteForce?: boolean): void;
  31104. /**
  31105. * Set the compressed texture format to use, based on the formats you have, and the formats
  31106. * supported by the hardware / browser.
  31107. *
  31108. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31109. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31110. * to API arguments needed to compressed textures. This puts the burden on the container
  31111. * generator to house the arcane code for determining these for current & future formats.
  31112. *
  31113. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31114. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31115. *
  31116. * Note: The result of this call is not taken into account when a texture is base64.
  31117. *
  31118. * @param formatsAvailable defines the list of those format families you have created
  31119. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31120. *
  31121. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31122. * @returns The extension selected.
  31123. */
  31124. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31125. /** @hidden */
  31126. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31127. min: number;
  31128. mag: number;
  31129. };
  31130. /** @hidden */
  31131. _createTexture(): WebGLTexture;
  31132. /**
  31133. * Usually called from Texture.ts.
  31134. * Passed information to create a WebGLTexture
  31135. * @param urlArg defines a value which contains one of the following:
  31136. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31137. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31138. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31139. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31140. * @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)
  31141. * @param scene needed for loading to the correct scene
  31142. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31143. * @param onLoad optional callback to be called upon successful completion
  31144. * @param onError optional callback to be called upon failure
  31145. * @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
  31146. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31147. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31148. * @param forcedExtension defines the extension to use to pick the right loader
  31149. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31150. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31151. */
  31152. 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;
  31153. /**
  31154. * @hidden
  31155. * Rescales a texture
  31156. * @param source input texutre
  31157. * @param destination destination texture
  31158. * @param scene scene to use to render the resize
  31159. * @param internalFormat format to use when resizing
  31160. * @param onComplete callback to be called when resize has completed
  31161. */
  31162. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31163. private _unpackFlipYCached;
  31164. /**
  31165. * In case you are sharing the context with other applications, it might
  31166. * be interested to not cache the unpack flip y state to ensure a consistent
  31167. * value would be set.
  31168. */
  31169. enableUnpackFlipYCached: boolean;
  31170. /** @hidden */
  31171. _unpackFlipY(value: boolean): void;
  31172. /** @hidden */
  31173. _getUnpackAlignement(): number;
  31174. /**
  31175. * Creates a dynamic texture
  31176. * @param width defines the width of the texture
  31177. * @param height defines the height of the texture
  31178. * @param generateMipMaps defines if the engine should generate the mip levels
  31179. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31180. * @returns the dynamic texture inside an InternalTexture
  31181. */
  31182. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31183. /**
  31184. * Update the sampling mode of a given texture
  31185. * @param samplingMode defines the required sampling mode
  31186. * @param texture defines the texture to update
  31187. */
  31188. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31189. /**
  31190. * Update the content of a dynamic texture
  31191. * @param texture defines the texture to update
  31192. * @param canvas defines the canvas containing the source
  31193. * @param invertY defines if data must be stored with Y axis inverted
  31194. * @param premulAlpha defines if alpha is stored as premultiplied
  31195. * @param format defines the format of the data
  31196. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31197. */
  31198. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31199. /**
  31200. * Update a video texture
  31201. * @param texture defines the texture to update
  31202. * @param video defines the video element to use
  31203. * @param invertY defines if data must be stored with Y axis inverted
  31204. */
  31205. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31206. /**
  31207. * Updates a depth texture Comparison Mode and Function.
  31208. * If the comparison Function is equal to 0, the mode will be set to none.
  31209. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31210. * @param texture The texture to set the comparison function for
  31211. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31212. */
  31213. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31214. /** @hidden */
  31215. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31216. width: number;
  31217. height: number;
  31218. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31219. /**
  31220. * Creates a depth stencil texture.
  31221. * This is only available in WebGL 2 or with the depth texture extension available.
  31222. * @param size The size of face edge in the texture.
  31223. * @param options The options defining the texture.
  31224. * @returns The texture
  31225. */
  31226. createDepthStencilTexture(size: number | {
  31227. width: number;
  31228. height: number;
  31229. }, options: DepthTextureCreationOptions): InternalTexture;
  31230. /**
  31231. * Creates a depth stencil texture.
  31232. * This is only available in WebGL 2 or with the depth texture extension available.
  31233. * @param size The size of face edge in the texture.
  31234. * @param options The options defining the texture.
  31235. * @returns The texture
  31236. */
  31237. private _createDepthStencilTexture;
  31238. /**
  31239. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31240. * @param renderTarget The render target to set the frame buffer for
  31241. */
  31242. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31243. /**
  31244. * Creates a new render target texture
  31245. * @param size defines the size of the texture
  31246. * @param options defines the options used to create the texture
  31247. * @returns a new render target texture stored in an InternalTexture
  31248. */
  31249. createRenderTargetTexture(size: number | {
  31250. width: number;
  31251. height: number;
  31252. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31253. /** @hidden */
  31254. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31255. /**
  31256. * Updates the sample count of a render target texture
  31257. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31258. * @param texture defines the texture to update
  31259. * @param samples defines the sample count to set
  31260. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31261. */
  31262. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31263. /** @hidden */
  31264. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31265. /** @hidden */
  31266. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31267. /** @hidden */
  31268. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31269. /** @hidden */
  31270. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31271. /**
  31272. * @hidden
  31273. */
  31274. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31275. private _prepareWebGLTextureContinuation;
  31276. private _prepareWebGLTexture;
  31277. /** @hidden */
  31278. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31279. /** @hidden */
  31280. _releaseFramebufferObjects(texture: InternalTexture): void;
  31281. /** @hidden */
  31282. _releaseTexture(texture: InternalTexture): void;
  31283. private setProgram;
  31284. private _boundUniforms;
  31285. /**
  31286. * Binds an effect to the webGL context
  31287. * @param effect defines the effect to bind
  31288. */
  31289. bindSamplers(effect: Effect): void;
  31290. private _activateCurrentTexture;
  31291. /** @hidden */
  31292. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31293. /** @hidden */
  31294. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31295. /**
  31296. * Sets a texture to the webGL context from a postprocess
  31297. * @param channel defines the channel to use
  31298. * @param postProcess defines the source postprocess
  31299. */
  31300. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31301. /**
  31302. * Binds the output of the passed in post process to the texture channel specified
  31303. * @param channel The channel the texture should be bound to
  31304. * @param postProcess The post process which's output should be bound
  31305. */
  31306. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31307. /**
  31308. * Unbind all textures from the webGL context
  31309. */
  31310. unbindAllTextures(): void;
  31311. /**
  31312. * Sets a texture to the according uniform.
  31313. * @param channel The texture channel
  31314. * @param uniform The uniform to set
  31315. * @param texture The texture to apply
  31316. */
  31317. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31318. /**
  31319. * Sets a depth stencil texture from a render target to the according uniform.
  31320. * @param channel The texture channel
  31321. * @param uniform The uniform to set
  31322. * @param texture The render target texture containing the depth stencil texture to apply
  31323. */
  31324. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31325. private _bindSamplerUniformToChannel;
  31326. private _getTextureWrapMode;
  31327. private _setTexture;
  31328. /**
  31329. * Sets an array of texture to the webGL context
  31330. * @param channel defines the channel where the texture array must be set
  31331. * @param uniform defines the associated uniform location
  31332. * @param textures defines the array of textures to bind
  31333. */
  31334. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31335. /** @hidden */
  31336. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31337. private _setTextureParameterFloat;
  31338. private _setTextureParameterInteger;
  31339. /**
  31340. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31341. * @param x defines the x coordinate of the rectangle where pixels must be read
  31342. * @param y defines the y coordinate of the rectangle where pixels must be read
  31343. * @param width defines the width of the rectangle where pixels must be read
  31344. * @param height defines the height of the rectangle where pixels must be read
  31345. * @returns a Uint8Array containing RGBA colors
  31346. */
  31347. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31348. /**
  31349. * Add an externaly attached data from its key.
  31350. * This method call will fail and return false, if such key already exists.
  31351. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31352. * @param key the unique key that identifies the data
  31353. * @param data the data object to associate to the key for this Engine instance
  31354. * @return true if no such key were already present and the data was added successfully, false otherwise
  31355. */
  31356. addExternalData<T>(key: string, data: T): boolean;
  31357. /**
  31358. * Get an externaly attached data from its key
  31359. * @param key the unique key that identifies the data
  31360. * @return the associated data, if present (can be null), or undefined if not present
  31361. */
  31362. getExternalData<T>(key: string): T;
  31363. /**
  31364. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31365. * @param key the unique key that identifies the data
  31366. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31367. * @return the associated data, can be null if the factory returned null.
  31368. */
  31369. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31370. /**
  31371. * Remove an externaly attached data from the Engine instance
  31372. * @param key the unique key that identifies the data
  31373. * @return true if the data was successfully removed, false if it doesn't exist
  31374. */
  31375. removeExternalData(key: string): boolean;
  31376. /**
  31377. * Unbind all vertex attributes from the webGL context
  31378. */
  31379. unbindAllAttributes(): void;
  31380. /**
  31381. * 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
  31382. */
  31383. releaseEffects(): void;
  31384. /**
  31385. * Dispose and release all associated resources
  31386. */
  31387. dispose(): void;
  31388. /**
  31389. * Display the loading screen
  31390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31391. */
  31392. displayLoadingUI(): void;
  31393. /**
  31394. * Hide the loading screen
  31395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31396. */
  31397. hideLoadingUI(): void;
  31398. /**
  31399. * Gets the current loading screen object
  31400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31401. */
  31402. /**
  31403. * Sets the current loading screen object
  31404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31405. */
  31406. loadingScreen: ILoadingScreen;
  31407. /**
  31408. * Sets the current loading screen text
  31409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31410. */
  31411. loadingUIText: string;
  31412. /**
  31413. * Sets the current loading screen background color
  31414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31415. */
  31416. loadingUIBackgroundColor: string;
  31417. /**
  31418. * Attach a new callback raised when context lost event is fired
  31419. * @param callback defines the callback to call
  31420. */
  31421. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31422. /**
  31423. * Attach a new callback raised when context restored event is fired
  31424. * @param callback defines the callback to call
  31425. */
  31426. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31427. /**
  31428. * Gets the source code of the vertex shader associated with a specific webGL program
  31429. * @param program defines the program to use
  31430. * @returns a string containing the source code of the vertex shader associated with the program
  31431. */
  31432. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31433. /**
  31434. * Gets the source code of the fragment shader associated with a specific webGL program
  31435. * @param program defines the program to use
  31436. * @returns a string containing the source code of the fragment shader associated with the program
  31437. */
  31438. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31439. /**
  31440. * Get the current error code of the webGL context
  31441. * @returns the error code
  31442. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31443. */
  31444. getError(): number;
  31445. /**
  31446. * Gets the current framerate
  31447. * @returns a number representing the framerate
  31448. */
  31449. getFps(): number;
  31450. /**
  31451. * Gets the time spent between current and previous frame
  31452. * @returns a number representing the delta time in ms
  31453. */
  31454. getDeltaTime(): number;
  31455. private _measureFps;
  31456. /** @hidden */
  31457. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31458. private _canRenderToFloatFramebuffer;
  31459. private _canRenderToHalfFloatFramebuffer;
  31460. private _canRenderToFramebuffer;
  31461. /** @hidden */
  31462. _getWebGLTextureType(type: number): number;
  31463. /** @hidden */
  31464. _getInternalFormat(format: number): number;
  31465. /** @hidden */
  31466. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31467. /** @hidden */
  31468. _getRGBAMultiSampleBufferFormat(type: number): number;
  31469. /** @hidden */
  31470. _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;
  31471. /** @hidden */
  31472. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31473. /**
  31474. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31475. * @returns true if the engine can be created
  31476. * @ignorenaming
  31477. */
  31478. static isSupported(): boolean;
  31479. /**
  31480. * Find the next highest power of two.
  31481. * @param x Number to start search from.
  31482. * @return Next highest power of two.
  31483. */
  31484. static CeilingPOT(x: number): number;
  31485. /**
  31486. * Find the next lowest power of two.
  31487. * @param x Number to start search from.
  31488. * @return Next lowest power of two.
  31489. */
  31490. static FloorPOT(x: number): number;
  31491. /**
  31492. * Find the nearest power of two.
  31493. * @param x Number to start search from.
  31494. * @return Next nearest power of two.
  31495. */
  31496. static NearestPOT(x: number): number;
  31497. /**
  31498. * Get the closest exponent of two
  31499. * @param value defines the value to approximate
  31500. * @param max defines the maximum value to return
  31501. * @param mode defines how to define the closest value
  31502. * @returns closest exponent of two of the given value
  31503. */
  31504. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31505. /**
  31506. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31507. * @param func - the function to be called
  31508. * @param requester - the object that will request the next frame. Falls back to window.
  31509. * @returns frame number
  31510. */
  31511. static QueueNewFrame(func: () => void, requester?: any): number;
  31512. /**
  31513. * Ask the browser to promote the current element to pointerlock mode
  31514. * @param element defines the DOM element to promote
  31515. */
  31516. static _RequestPointerlock(element: HTMLElement): void;
  31517. /**
  31518. * Asks the browser to exit pointerlock mode
  31519. */
  31520. static _ExitPointerlock(): void;
  31521. /**
  31522. * Ask the browser to promote the current element to fullscreen rendering mode
  31523. * @param element defines the DOM element to promote
  31524. */
  31525. static _RequestFullscreen(element: HTMLElement): void;
  31526. /**
  31527. * Asks the browser to exit fullscreen mode
  31528. */
  31529. static _ExitFullscreen(): void;
  31530. }
  31531. }
  31532. declare module BABYLON {
  31533. /**
  31534. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31535. * during the life time of the application.
  31536. */
  31537. export class EngineStore {
  31538. /** Gets the list of created engines */
  31539. static Instances: Engine[];
  31540. /** @hidden */
  31541. static _LastCreatedScene: Nullable<Scene>;
  31542. /**
  31543. * Gets the latest created engine
  31544. */
  31545. static readonly LastCreatedEngine: Nullable<Engine>;
  31546. /**
  31547. * Gets the latest created scene
  31548. */
  31549. static readonly LastCreatedScene: Nullable<Scene>;
  31550. /**
  31551. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31552. * @ignorenaming
  31553. */
  31554. static UseFallbackTexture: boolean;
  31555. /**
  31556. * Texture content used if a texture cannot loaded
  31557. * @ignorenaming
  31558. */
  31559. static FallbackTexture: string;
  31560. }
  31561. }
  31562. declare module BABYLON {
  31563. /**
  31564. * Helper class that provides a small promise polyfill
  31565. */
  31566. export class PromisePolyfill {
  31567. /**
  31568. * Static function used to check if the polyfill is required
  31569. * If this is the case then the function will inject the polyfill to window.Promise
  31570. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31571. */
  31572. static Apply(force?: boolean): void;
  31573. }
  31574. }
  31575. declare module BABYLON {
  31576. /**
  31577. * Interface for screenshot methods with describe argument called `size` as object with options
  31578. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31579. */
  31580. export interface IScreenshotSize {
  31581. /**
  31582. * number in pixels for canvas height
  31583. */
  31584. height?: number;
  31585. /**
  31586. * multiplier allowing render at a higher or lower resolution
  31587. * If value is defined then height and width will be ignored and taken from camera
  31588. */
  31589. precision?: number;
  31590. /**
  31591. * number in pixels for canvas width
  31592. */
  31593. width?: number;
  31594. }
  31595. }
  31596. declare module BABYLON {
  31597. interface IColor4Like {
  31598. r: float;
  31599. g: float;
  31600. b: float;
  31601. a: float;
  31602. }
  31603. /**
  31604. * Class containing a set of static utilities functions
  31605. */
  31606. export class Tools {
  31607. /**
  31608. * Gets or sets the base URL to use to load assets
  31609. */
  31610. static BaseUrl: string;
  31611. /**
  31612. * Enable/Disable Custom HTTP Request Headers globally.
  31613. * default = false
  31614. * @see CustomRequestHeaders
  31615. */
  31616. static UseCustomRequestHeaders: boolean;
  31617. /**
  31618. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31619. * i.e. when loading files, where the server/service expects an Authorization header
  31620. */
  31621. static CustomRequestHeaders: {
  31622. [key: string]: string;
  31623. };
  31624. /**
  31625. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31626. */
  31627. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31628. /**
  31629. * Default behaviour for cors in the application.
  31630. * It can be a string if the expected behavior is identical in the entire app.
  31631. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31632. */
  31633. static CorsBehavior: string | ((url: string | string[]) => string);
  31634. /**
  31635. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31636. * @ignorenaming
  31637. */
  31638. static UseFallbackTexture: boolean;
  31639. /**
  31640. * Use this object to register external classes like custom textures or material
  31641. * to allow the laoders to instantiate them
  31642. */
  31643. static RegisteredExternalClasses: {
  31644. [key: string]: Object;
  31645. };
  31646. /**
  31647. * Texture content used if a texture cannot loaded
  31648. * @ignorenaming
  31649. */
  31650. static fallbackTexture: string;
  31651. /**
  31652. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31653. * @param u defines the coordinate on X axis
  31654. * @param v defines the coordinate on Y axis
  31655. * @param width defines the width of the source data
  31656. * @param height defines the height of the source data
  31657. * @param pixels defines the source byte array
  31658. * @param color defines the output color
  31659. */
  31660. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31661. /**
  31662. * Interpolates between a and b via alpha
  31663. * @param a The lower value (returned when alpha = 0)
  31664. * @param b The upper value (returned when alpha = 1)
  31665. * @param alpha The interpolation-factor
  31666. * @return The mixed value
  31667. */
  31668. static Mix(a: number, b: number, alpha: number): number;
  31669. /**
  31670. * Tries to instantiate a new object from a given class name
  31671. * @param className defines the class name to instantiate
  31672. * @returns the new object or null if the system was not able to do the instantiation
  31673. */
  31674. static Instantiate(className: string): any;
  31675. /**
  31676. * Provides a slice function that will work even on IE
  31677. * @param data defines the array to slice
  31678. * @param start defines the start of the data (optional)
  31679. * @param end defines the end of the data (optional)
  31680. * @returns the new sliced array
  31681. */
  31682. static Slice<T>(data: T, start?: number, end?: number): T;
  31683. /**
  31684. * Polyfill for setImmediate
  31685. * @param action defines the action to execute after the current execution block
  31686. */
  31687. static SetImmediate(action: () => void): void;
  31688. /**
  31689. * Function indicating if a number is an exponent of 2
  31690. * @param value defines the value to test
  31691. * @returns true if the value is an exponent of 2
  31692. */
  31693. static IsExponentOfTwo(value: number): boolean;
  31694. private static _tmpFloatArray;
  31695. /**
  31696. * Returns the nearest 32-bit single precision float representation of a Number
  31697. * @param value A Number. If the parameter is of a different type, it will get converted
  31698. * to a number or to NaN if it cannot be converted
  31699. * @returns number
  31700. */
  31701. static FloatRound(value: number): number;
  31702. /**
  31703. * Extracts the filename from a path
  31704. * @param path defines the path to use
  31705. * @returns the filename
  31706. */
  31707. static GetFilename(path: string): string;
  31708. /**
  31709. * Extracts the "folder" part of a path (everything before the filename).
  31710. * @param uri The URI to extract the info from
  31711. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31712. * @returns The "folder" part of the path
  31713. */
  31714. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31715. /**
  31716. * Extracts text content from a DOM element hierarchy
  31717. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31718. */
  31719. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31720. /**
  31721. * Convert an angle in radians to degrees
  31722. * @param angle defines the angle to convert
  31723. * @returns the angle in degrees
  31724. */
  31725. static ToDegrees(angle: number): number;
  31726. /**
  31727. * Convert an angle in degrees to radians
  31728. * @param angle defines the angle to convert
  31729. * @returns the angle in radians
  31730. */
  31731. static ToRadians(angle: number): number;
  31732. /**
  31733. * Encode a buffer to a base64 string
  31734. * @param buffer defines the buffer to encode
  31735. * @returns the encoded string
  31736. */
  31737. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31738. /**
  31739. * Returns an array if obj is not an array
  31740. * @param obj defines the object to evaluate as an array
  31741. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31742. * @returns either obj directly if obj is an array or a new array containing obj
  31743. */
  31744. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31745. /**
  31746. * Gets the pointer prefix to use
  31747. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31748. */
  31749. static GetPointerPrefix(): string;
  31750. /**
  31751. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31752. * @param url define the url we are trying
  31753. * @param element define the dom element where to configure the cors policy
  31754. */
  31755. static SetCorsBehavior(url: string | string[], element: {
  31756. crossOrigin: string | null;
  31757. }): void;
  31758. /**
  31759. * Removes unwanted characters from an url
  31760. * @param url defines the url to clean
  31761. * @returns the cleaned url
  31762. */
  31763. static CleanUrl(url: string): string;
  31764. /**
  31765. * Gets or sets a function used to pre-process url before using them to load assets
  31766. */
  31767. static PreprocessUrl: (url: string) => string;
  31768. /**
  31769. * Loads an image as an HTMLImageElement.
  31770. * @param input url string, ArrayBuffer, or Blob to load
  31771. * @param onLoad callback called when the image successfully loads
  31772. * @param onError callback called when the image fails to load
  31773. * @param offlineProvider offline provider for caching
  31774. * @returns the HTMLImageElement of the loaded image
  31775. */
  31776. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31777. /**
  31778. * Loads a file
  31779. * @param url url string, ArrayBuffer, or Blob to load
  31780. * @param onSuccess callback called when the file successfully loads
  31781. * @param onProgress callback called while file is loading (if the server supports this mode)
  31782. * @param offlineProvider defines the offline provider for caching
  31783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31784. * @param onError callback called when the file fails to load
  31785. * @returns a file request object
  31786. */
  31787. 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;
  31788. /**
  31789. * Loads a file from a url
  31790. * @param url the file url to load
  31791. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31792. */
  31793. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31794. /**
  31795. * Load a script (identified by an url). When the url returns, the
  31796. * content of this file is added into a new script element, attached to the DOM (body element)
  31797. * @param scriptUrl defines the url of the script to laod
  31798. * @param onSuccess defines the callback called when the script is loaded
  31799. * @param onError defines the callback to call if an error occurs
  31800. * @param scriptId defines the id of the script element
  31801. */
  31802. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31803. /**
  31804. * Load an asynchronous script (identified by an url). When the url returns, the
  31805. * content of this file is added into a new script element, attached to the DOM (body element)
  31806. * @param scriptUrl defines the url of the script to laod
  31807. * @param scriptId defines the id of the script element
  31808. * @returns a promise request object
  31809. */
  31810. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31811. /**
  31812. * Loads a file from a blob
  31813. * @param fileToLoad defines the blob to use
  31814. * @param callback defines the callback to call when data is loaded
  31815. * @param progressCallback defines the callback to call during loading process
  31816. * @returns a file request object
  31817. */
  31818. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31819. /**
  31820. * Loads a file
  31821. * @param fileToLoad defines the file to load
  31822. * @param callback defines the callback to call when data is loaded
  31823. * @param progressCallBack defines the callback to call during loading process
  31824. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31825. * @returns a file request object
  31826. */
  31827. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31828. /**
  31829. * Creates a data url from a given string content
  31830. * @param content defines the content to convert
  31831. * @returns the new data url link
  31832. */
  31833. static FileAsURL(content: string): string;
  31834. /**
  31835. * Format the given number to a specific decimal format
  31836. * @param value defines the number to format
  31837. * @param decimals defines the number of decimals to use
  31838. * @returns the formatted string
  31839. */
  31840. static Format(value: number, decimals?: number): string;
  31841. /**
  31842. * Tries to copy an object by duplicating every property
  31843. * @param source defines the source object
  31844. * @param destination defines the target object
  31845. * @param doNotCopyList defines a list of properties to avoid
  31846. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31847. */
  31848. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31849. /**
  31850. * Gets a boolean indicating if the given object has no own property
  31851. * @param obj defines the object to test
  31852. * @returns true if object has no own property
  31853. */
  31854. static IsEmpty(obj: any): boolean;
  31855. /**
  31856. * Function used to register events at window level
  31857. * @param events defines the events to register
  31858. */
  31859. static RegisterTopRootEvents(events: {
  31860. name: string;
  31861. handler: Nullable<(e: FocusEvent) => any>;
  31862. }[]): void;
  31863. /**
  31864. * Function used to unregister events from window level
  31865. * @param events defines the events to unregister
  31866. */
  31867. static UnregisterTopRootEvents(events: {
  31868. name: string;
  31869. handler: Nullable<(e: FocusEvent) => any>;
  31870. }[]): void;
  31871. /**
  31872. * @ignore
  31873. */
  31874. static _ScreenshotCanvas: HTMLCanvasElement;
  31875. /**
  31876. * Dumps the current bound framebuffer
  31877. * @param width defines the rendering width
  31878. * @param height defines the rendering height
  31879. * @param engine defines the hosting engine
  31880. * @param successCallback defines the callback triggered once the data are available
  31881. * @param mimeType defines the mime type of the result
  31882. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31883. */
  31884. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31885. /**
  31886. * Converts the canvas data to blob.
  31887. * This acts as a polyfill for browsers not supporting the to blob function.
  31888. * @param canvas Defines the canvas to extract the data from
  31889. * @param successCallback Defines the callback triggered once the data are available
  31890. * @param mimeType Defines the mime type of the result
  31891. */
  31892. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31893. /**
  31894. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31895. * @param successCallback defines the callback triggered once the data are available
  31896. * @param mimeType defines the mime type of the result
  31897. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31898. */
  31899. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31900. /**
  31901. * Downloads a blob in the browser
  31902. * @param blob defines the blob to download
  31903. * @param fileName defines the name of the downloaded file
  31904. */
  31905. static Download(blob: Blob, fileName: string): void;
  31906. /**
  31907. * Captures a screenshot of the current rendering
  31908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31909. * @param engine defines the rendering engine
  31910. * @param camera defines the source camera
  31911. * @param size This parameter can be set to a single number or to an object with the
  31912. * following (optional) properties: precision, width, height. If a single number is passed,
  31913. * it will be used for both width and height. If an object is passed, the screenshot size
  31914. * will be derived from the parameters. The precision property is a multiplier allowing
  31915. * rendering at a higher or lower resolution
  31916. * @param successCallback defines the callback receives a single parameter which contains the
  31917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31918. * src parameter of an <img> to display it
  31919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31920. * Check your browser for supported MIME types
  31921. */
  31922. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31923. /**
  31924. * Captures a screenshot of the current rendering
  31925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31926. * @param engine defines the rendering engine
  31927. * @param camera defines the source camera
  31928. * @param size This parameter can be set to a single number or to an object with the
  31929. * following (optional) properties: precision, width, height. If a single number is passed,
  31930. * it will be used for both width and height. If an object is passed, the screenshot size
  31931. * will be derived from the parameters. The precision property is a multiplier allowing
  31932. * rendering at a higher or lower resolution
  31933. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31934. * Check your browser for supported MIME types
  31935. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31936. * to the src parameter of an <img> to display it
  31937. */
  31938. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31939. /**
  31940. * Generates an image screenshot from the specified camera.
  31941. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31942. * @param engine The engine to use for rendering
  31943. * @param camera The camera to use for rendering
  31944. * @param size This parameter can be set to a single number or to an object with the
  31945. * following (optional) properties: precision, width, height. If a single number is passed,
  31946. * it will be used for both width and height. If an object is passed, the screenshot size
  31947. * will be derived from the parameters. The precision property is a multiplier allowing
  31948. * rendering at a higher or lower resolution
  31949. * @param successCallback The callback receives a single parameter which contains the
  31950. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31951. * src parameter of an <img> to display it
  31952. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31953. * Check your browser for supported MIME types
  31954. * @param samples Texture samples (default: 1)
  31955. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31956. * @param fileName A name for for the downloaded file.
  31957. */
  31958. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31959. /**
  31960. * Generates an image screenshot from the specified camera.
  31961. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31962. * @param engine The engine to use for rendering
  31963. * @param camera The camera to use for rendering
  31964. * @param size This parameter can be set to a single number or to an object with the
  31965. * following (optional) properties: precision, width, height. If a single number is passed,
  31966. * it will be used for both width and height. If an object is passed, the screenshot size
  31967. * will be derived from the parameters. The precision property is a multiplier allowing
  31968. * rendering at a higher or lower resolution
  31969. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31970. * Check your browser for supported MIME types
  31971. * @param samples Texture samples (default: 1)
  31972. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31973. * @param fileName A name for for the downloaded file.
  31974. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31975. * to the src parameter of an <img> to display it
  31976. */
  31977. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31978. /**
  31979. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31980. * Be aware Math.random() could cause collisions, but:
  31981. * "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"
  31982. * @returns a pseudo random id
  31983. */
  31984. static RandomId(): string;
  31985. /**
  31986. * Test if the given uri is a base64 string
  31987. * @param uri The uri to test
  31988. * @return True if the uri is a base64 string or false otherwise
  31989. */
  31990. static IsBase64(uri: string): boolean;
  31991. /**
  31992. * Decode the given base64 uri.
  31993. * @param uri The uri to decode
  31994. * @return The decoded base64 data.
  31995. */
  31996. static DecodeBase64(uri: string): ArrayBuffer;
  31997. /**
  31998. * Gets the absolute url.
  31999. * @param url the input url
  32000. * @return the absolute url
  32001. */
  32002. static GetAbsoluteUrl(url: string): string;
  32003. /**
  32004. * No log
  32005. */
  32006. static readonly NoneLogLevel: number;
  32007. /**
  32008. * Only message logs
  32009. */
  32010. static readonly MessageLogLevel: number;
  32011. /**
  32012. * Only warning logs
  32013. */
  32014. static readonly WarningLogLevel: number;
  32015. /**
  32016. * Only error logs
  32017. */
  32018. static readonly ErrorLogLevel: number;
  32019. /**
  32020. * All logs
  32021. */
  32022. static readonly AllLogLevel: number;
  32023. /**
  32024. * Gets a value indicating the number of loading errors
  32025. * @ignorenaming
  32026. */
  32027. static readonly errorsCount: number;
  32028. /**
  32029. * Callback called when a new log is added
  32030. */
  32031. static OnNewCacheEntry: (entry: string) => void;
  32032. /**
  32033. * Log a message to the console
  32034. * @param message defines the message to log
  32035. */
  32036. static Log(message: string): void;
  32037. /**
  32038. * Write a warning message to the console
  32039. * @param message defines the message to log
  32040. */
  32041. static Warn(message: string): void;
  32042. /**
  32043. * Write an error message to the console
  32044. * @param message defines the message to log
  32045. */
  32046. static Error(message: string): void;
  32047. /**
  32048. * Gets current log cache (list of logs)
  32049. */
  32050. static readonly LogCache: string;
  32051. /**
  32052. * Clears the log cache
  32053. */
  32054. static ClearLogCache(): void;
  32055. /**
  32056. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32057. */
  32058. static LogLevels: number;
  32059. /**
  32060. * Checks if the window object exists
  32061. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32062. */
  32063. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32064. /**
  32065. * No performance log
  32066. */
  32067. static readonly PerformanceNoneLogLevel: number;
  32068. /**
  32069. * Use user marks to log performance
  32070. */
  32071. static readonly PerformanceUserMarkLogLevel: number;
  32072. /**
  32073. * Log performance to the console
  32074. */
  32075. static readonly PerformanceConsoleLogLevel: number;
  32076. private static _performance;
  32077. /**
  32078. * Sets the current performance log level
  32079. */
  32080. static PerformanceLogLevel: number;
  32081. private static _StartPerformanceCounterDisabled;
  32082. private static _EndPerformanceCounterDisabled;
  32083. private static _StartUserMark;
  32084. private static _EndUserMark;
  32085. private static _StartPerformanceConsole;
  32086. private static _EndPerformanceConsole;
  32087. /**
  32088. * Starts a performance counter
  32089. */
  32090. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32091. /**
  32092. * Ends a specific performance coutner
  32093. */
  32094. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32095. /**
  32096. * Gets either window.performance.now() if supported or Date.now() else
  32097. */
  32098. static readonly Now: number;
  32099. /**
  32100. * This method will return the name of the class used to create the instance of the given object.
  32101. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32102. * @param object the object to get the class name from
  32103. * @param isType defines if the object is actually a type
  32104. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32105. */
  32106. static GetClassName(object: any, isType?: boolean): string;
  32107. /**
  32108. * Gets the first element of an array satisfying a given predicate
  32109. * @param array defines the array to browse
  32110. * @param predicate defines the predicate to use
  32111. * @returns null if not found or the element
  32112. */
  32113. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32114. /**
  32115. * This method will return the name of the full name of the class, including its owning module (if any).
  32116. * 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).
  32117. * @param object the object to get the class name from
  32118. * @param isType defines if the object is actually a type
  32119. * @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.
  32120. * @ignorenaming
  32121. */
  32122. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32123. /**
  32124. * Returns a promise that resolves after the given amount of time.
  32125. * @param delay Number of milliseconds to delay
  32126. * @returns Promise that resolves after the given amount of time
  32127. */
  32128. static DelayAsync(delay: number): Promise<void>;
  32129. }
  32130. /**
  32131. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32132. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32133. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32134. * @param name The name of the class, case should be preserved
  32135. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32136. */
  32137. export function className(name: string, module?: string): (target: Object) => void;
  32138. /**
  32139. * An implementation of a loop for asynchronous functions.
  32140. */
  32141. export class AsyncLoop {
  32142. /**
  32143. * Defines the number of iterations for the loop
  32144. */
  32145. iterations: number;
  32146. /**
  32147. * Defines the current index of the loop.
  32148. */
  32149. index: number;
  32150. private _done;
  32151. private _fn;
  32152. private _successCallback;
  32153. /**
  32154. * Constructor.
  32155. * @param iterations the number of iterations.
  32156. * @param func the function to run each iteration
  32157. * @param successCallback the callback that will be called upon succesful execution
  32158. * @param offset starting offset.
  32159. */
  32160. constructor(
  32161. /**
  32162. * Defines the number of iterations for the loop
  32163. */
  32164. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32165. /**
  32166. * Execute the next iteration. Must be called after the last iteration was finished.
  32167. */
  32168. executeNext(): void;
  32169. /**
  32170. * Break the loop and run the success callback.
  32171. */
  32172. breakLoop(): void;
  32173. /**
  32174. * Create and run an async loop.
  32175. * @param iterations the number of iterations.
  32176. * @param fn the function to run each iteration
  32177. * @param successCallback the callback that will be called upon succesful execution
  32178. * @param offset starting offset.
  32179. * @returns the created async loop object
  32180. */
  32181. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32182. /**
  32183. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32184. * @param iterations total number of iterations
  32185. * @param syncedIterations number of synchronous iterations in each async iteration.
  32186. * @param fn the function to call each iteration.
  32187. * @param callback a success call back that will be called when iterating stops.
  32188. * @param breakFunction a break condition (optional)
  32189. * @param timeout timeout settings for the setTimeout function. default - 0.
  32190. * @returns the created async loop object
  32191. */
  32192. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32193. }
  32194. }
  32195. declare module BABYLON {
  32196. /** @hidden */
  32197. export interface ICollisionCoordinator {
  32198. createCollider(): Collider;
  32199. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32200. init(scene: Scene): void;
  32201. }
  32202. /** @hidden */
  32203. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32204. private _scene;
  32205. private _scaledPosition;
  32206. private _scaledVelocity;
  32207. private _finalPosition;
  32208. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32209. createCollider(): Collider;
  32210. init(scene: Scene): void;
  32211. private _collideWithWorld;
  32212. }
  32213. }
  32214. declare module BABYLON {
  32215. /**
  32216. * Class used to manage all inputs for the scene.
  32217. */
  32218. export class InputManager {
  32219. /** The distance in pixel that you have to move to prevent some events */
  32220. static DragMovementThreshold: number;
  32221. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32222. static LongPressDelay: number;
  32223. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32224. static DoubleClickDelay: number;
  32225. /** If you need to check double click without raising a single click at first click, enable this flag */
  32226. static ExclusiveDoubleClickMode: boolean;
  32227. private _wheelEventName;
  32228. private _onPointerMove;
  32229. private _onPointerDown;
  32230. private _onPointerUp;
  32231. private _initClickEvent;
  32232. private _initActionManager;
  32233. private _delayedSimpleClick;
  32234. private _delayedSimpleClickTimeout;
  32235. private _previousDelayedSimpleClickTimeout;
  32236. private _meshPickProceed;
  32237. private _previousButtonPressed;
  32238. private _currentPickResult;
  32239. private _previousPickResult;
  32240. private _totalPointersPressed;
  32241. private _doubleClickOccured;
  32242. private _pointerOverMesh;
  32243. private _pickedDownMesh;
  32244. private _pickedUpMesh;
  32245. private _pointerX;
  32246. private _pointerY;
  32247. private _unTranslatedPointerX;
  32248. private _unTranslatedPointerY;
  32249. private _startingPointerPosition;
  32250. private _previousStartingPointerPosition;
  32251. private _startingPointerTime;
  32252. private _previousStartingPointerTime;
  32253. private _pointerCaptures;
  32254. private _onKeyDown;
  32255. private _onKeyUp;
  32256. private _onCanvasFocusObserver;
  32257. private _onCanvasBlurObserver;
  32258. private _scene;
  32259. /**
  32260. * Creates a new InputManager
  32261. * @param scene defines the hosting scene
  32262. */
  32263. constructor(scene: Scene);
  32264. /**
  32265. * Gets the mesh that is currently under the pointer
  32266. */
  32267. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32268. /**
  32269. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32270. */
  32271. readonly unTranslatedPointer: Vector2;
  32272. /**
  32273. * Gets or sets the current on-screen X position of the pointer
  32274. */
  32275. pointerX: number;
  32276. /**
  32277. * Gets or sets the current on-screen Y position of the pointer
  32278. */
  32279. pointerY: number;
  32280. private _updatePointerPosition;
  32281. private _processPointerMove;
  32282. private _setRayOnPointerInfo;
  32283. private _checkPrePointerObservable;
  32284. /**
  32285. * Use this method to simulate a pointer move on a mesh
  32286. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32287. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32288. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32289. */
  32290. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32291. /**
  32292. * Use this method to simulate a pointer down on a mesh
  32293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32296. */
  32297. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32298. private _processPointerDown;
  32299. /** @hidden */
  32300. _isPointerSwiping(): boolean;
  32301. /**
  32302. * Use this method to simulate a pointer up on a mesh
  32303. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32304. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32305. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32306. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32307. */
  32308. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32309. private _processPointerUp;
  32310. /**
  32311. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32312. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32313. * @returns true if the pointer was captured
  32314. */
  32315. isPointerCaptured(pointerId?: number): boolean;
  32316. /**
  32317. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32318. * @param attachUp defines if you want to attach events to pointerup
  32319. * @param attachDown defines if you want to attach events to pointerdown
  32320. * @param attachMove defines if you want to attach events to pointermove
  32321. */
  32322. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32323. /**
  32324. * Detaches all event handlers
  32325. */
  32326. detachControl(): void;
  32327. /**
  32328. * Force the value of meshUnderPointer
  32329. * @param mesh defines the mesh to use
  32330. */
  32331. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32332. /**
  32333. * Gets the mesh under the pointer
  32334. * @returns a Mesh or null if no mesh is under the pointer
  32335. */
  32336. getPointerOverMesh(): Nullable<AbstractMesh>;
  32337. }
  32338. }
  32339. declare module BABYLON {
  32340. /**
  32341. * Helper class used to generate session unique ID
  32342. */
  32343. export class UniqueIdGenerator {
  32344. private static _UniqueIdCounter;
  32345. /**
  32346. * Gets an unique (relatively to the current scene) Id
  32347. */
  32348. static readonly UniqueId: number;
  32349. }
  32350. }
  32351. declare module BABYLON {
  32352. /**
  32353. * This class defines the direct association between an animation and a target
  32354. */
  32355. export class TargetedAnimation {
  32356. /**
  32357. * Animation to perform
  32358. */
  32359. animation: Animation;
  32360. /**
  32361. * Target to animate
  32362. */
  32363. target: any;
  32364. /**
  32365. * Serialize the object
  32366. * @returns the JSON object representing the current entity
  32367. */
  32368. serialize(): any;
  32369. }
  32370. /**
  32371. * Use this class to create coordinated animations on multiple targets
  32372. */
  32373. export class AnimationGroup implements IDisposable {
  32374. /** The name of the animation group */
  32375. name: string;
  32376. private _scene;
  32377. private _targetedAnimations;
  32378. private _animatables;
  32379. private _from;
  32380. private _to;
  32381. private _isStarted;
  32382. private _isPaused;
  32383. private _speedRatio;
  32384. private _loopAnimation;
  32385. /**
  32386. * Gets or sets the unique id of the node
  32387. */
  32388. uniqueId: number;
  32389. /**
  32390. * This observable will notify when one animation have ended
  32391. */
  32392. onAnimationEndObservable: Observable<TargetedAnimation>;
  32393. /**
  32394. * Observer raised when one animation loops
  32395. */
  32396. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32397. /**
  32398. * This observable will notify when all animations have ended.
  32399. */
  32400. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32401. /**
  32402. * This observable will notify when all animations have paused.
  32403. */
  32404. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32405. /**
  32406. * This observable will notify when all animations are playing.
  32407. */
  32408. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32409. /**
  32410. * Gets the first frame
  32411. */
  32412. readonly from: number;
  32413. /**
  32414. * Gets the last frame
  32415. */
  32416. readonly to: number;
  32417. /**
  32418. * Define if the animations are started
  32419. */
  32420. readonly isStarted: boolean;
  32421. /**
  32422. * Gets a value indicating that the current group is playing
  32423. */
  32424. readonly isPlaying: boolean;
  32425. /**
  32426. * Gets or sets the speed ratio to use for all animations
  32427. */
  32428. /**
  32429. * Gets or sets the speed ratio to use for all animations
  32430. */
  32431. speedRatio: number;
  32432. /**
  32433. * Gets or sets if all animations should loop or not
  32434. */
  32435. loopAnimation: boolean;
  32436. /**
  32437. * Gets the targeted animations for this animation group
  32438. */
  32439. readonly targetedAnimations: Array<TargetedAnimation>;
  32440. /**
  32441. * returning the list of animatables controlled by this animation group.
  32442. */
  32443. readonly animatables: Array<Animatable>;
  32444. /**
  32445. * Instantiates a new Animation Group.
  32446. * This helps managing several animations at once.
  32447. * @see http://doc.babylonjs.com/how_to/group
  32448. * @param name Defines the name of the group
  32449. * @param scene Defines the scene the group belongs to
  32450. */
  32451. constructor(
  32452. /** The name of the animation group */
  32453. name: string, scene?: Nullable<Scene>);
  32454. /**
  32455. * Add an animation (with its target) in the group
  32456. * @param animation defines the animation we want to add
  32457. * @param target defines the target of the animation
  32458. * @returns the TargetedAnimation object
  32459. */
  32460. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32461. /**
  32462. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32463. * It can add constant keys at begin or end
  32464. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32465. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32466. * @returns the animation group
  32467. */
  32468. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32469. /**
  32470. * Start all animations on given targets
  32471. * @param loop defines if animations must loop
  32472. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32473. * @param from defines the from key (optional)
  32474. * @param to defines the to key (optional)
  32475. * @returns the current animation group
  32476. */
  32477. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32478. /**
  32479. * Pause all animations
  32480. * @returns the animation group
  32481. */
  32482. pause(): AnimationGroup;
  32483. /**
  32484. * Play all animations to initial state
  32485. * This function will start() the animations if they were not started or will restart() them if they were paused
  32486. * @param loop defines if animations must loop
  32487. * @returns the animation group
  32488. */
  32489. play(loop?: boolean): AnimationGroup;
  32490. /**
  32491. * Reset all animations to initial state
  32492. * @returns the animation group
  32493. */
  32494. reset(): AnimationGroup;
  32495. /**
  32496. * Restart animations from key 0
  32497. * @returns the animation group
  32498. */
  32499. restart(): AnimationGroup;
  32500. /**
  32501. * Stop all animations
  32502. * @returns the animation group
  32503. */
  32504. stop(): AnimationGroup;
  32505. /**
  32506. * Set animation weight for all animatables
  32507. * @param weight defines the weight to use
  32508. * @return the animationGroup
  32509. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32510. */
  32511. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32512. /**
  32513. * Synchronize and normalize all animatables with a source animatable
  32514. * @param root defines the root animatable to synchronize with
  32515. * @return the animationGroup
  32516. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32517. */
  32518. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32519. /**
  32520. * Goes to a specific frame in this animation group
  32521. * @param frame the frame number to go to
  32522. * @return the animationGroup
  32523. */
  32524. goToFrame(frame: number): AnimationGroup;
  32525. /**
  32526. * Dispose all associated resources
  32527. */
  32528. dispose(): void;
  32529. private _checkAnimationGroupEnded;
  32530. /**
  32531. * Clone the current animation group and returns a copy
  32532. * @param newName defines the name of the new group
  32533. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32534. * @returns the new aniamtion group
  32535. */
  32536. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32537. /**
  32538. * Serializes the animationGroup to an object
  32539. * @returns Serialized object
  32540. */
  32541. serialize(): any;
  32542. /**
  32543. * Returns a new AnimationGroup object parsed from the source provided.
  32544. * @param parsedAnimationGroup defines the source
  32545. * @param scene defines the scene that will receive the animationGroup
  32546. * @returns a new AnimationGroup
  32547. */
  32548. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32549. /**
  32550. * Returns the string "AnimationGroup"
  32551. * @returns "AnimationGroup"
  32552. */
  32553. getClassName(): string;
  32554. /**
  32555. * Creates a detailled string about the object
  32556. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32557. * @returns a string representing the object
  32558. */
  32559. toString(fullDetails?: boolean): string;
  32560. }
  32561. }
  32562. declare module BABYLON {
  32563. /**
  32564. * Define an interface for all classes that will hold resources
  32565. */
  32566. export interface IDisposable {
  32567. /**
  32568. * Releases all held resources
  32569. */
  32570. dispose(): void;
  32571. }
  32572. /** Interface defining initialization parameters for Scene class */
  32573. export interface SceneOptions {
  32574. /**
  32575. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32576. * It will improve performance when the number of geometries becomes important.
  32577. */
  32578. useGeometryUniqueIdsMap?: boolean;
  32579. /**
  32580. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32581. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32582. */
  32583. useMaterialMeshMap?: boolean;
  32584. /**
  32585. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32586. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32587. */
  32588. useClonedMeshhMap?: boolean;
  32589. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32590. virtual?: boolean;
  32591. }
  32592. /**
  32593. * Represents a scene to be rendered by the engine.
  32594. * @see http://doc.babylonjs.com/features/scene
  32595. */
  32596. export class Scene extends AbstractScene implements IAnimatable {
  32597. /** The fog is deactivated */
  32598. static readonly FOGMODE_NONE: number;
  32599. /** The fog density is following an exponential function */
  32600. static readonly FOGMODE_EXP: number;
  32601. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32602. static readonly FOGMODE_EXP2: number;
  32603. /** The fog density is following a linear function. */
  32604. static readonly FOGMODE_LINEAR: number;
  32605. /**
  32606. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32607. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32608. */
  32609. static MinDeltaTime: number;
  32610. /**
  32611. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32612. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32613. */
  32614. static MaxDeltaTime: number;
  32615. /**
  32616. * Factory used to create the default material.
  32617. * @param name The name of the material to create
  32618. * @param scene The scene to create the material for
  32619. * @returns The default material
  32620. */
  32621. static DefaultMaterialFactory(scene: Scene): Material;
  32622. /**
  32623. * Factory used to create the a collision coordinator.
  32624. * @returns The collision coordinator
  32625. */
  32626. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32627. /** @hidden */
  32628. _inputManager: InputManager;
  32629. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32630. cameraToUseForPointers: Nullable<Camera>;
  32631. /** @hidden */
  32632. readonly _isScene: boolean;
  32633. /**
  32634. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32635. */
  32636. autoClear: boolean;
  32637. /**
  32638. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32639. */
  32640. autoClearDepthAndStencil: boolean;
  32641. /**
  32642. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32643. */
  32644. clearColor: Color4;
  32645. /**
  32646. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32647. */
  32648. ambientColor: Color3;
  32649. /**
  32650. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32651. * It should only be one of the following (if not the default embedded one):
  32652. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32653. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32654. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32655. * The material properties need to be setup according to the type of texture in use.
  32656. */
  32657. environmentBRDFTexture: BaseTexture;
  32658. /** @hidden */
  32659. protected _environmentTexture: Nullable<BaseTexture>;
  32660. /**
  32661. * Texture used in all pbr material as the reflection texture.
  32662. * As in the majority of the scene they are the same (exception for multi room and so on),
  32663. * this is easier to reference from here than from all the materials.
  32664. */
  32665. /**
  32666. * Texture used in all pbr material as the reflection texture.
  32667. * As in the majority of the scene they are the same (exception for multi room and so on),
  32668. * this is easier to set here than in all the materials.
  32669. */
  32670. environmentTexture: Nullable<BaseTexture>;
  32671. /** @hidden */
  32672. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32673. /**
  32674. * Default image processing configuration used either in the rendering
  32675. * Forward main pass or through the imageProcessingPostProcess if present.
  32676. * As in the majority of the scene they are the same (exception for multi camera),
  32677. * this is easier to reference from here than from all the materials and post process.
  32678. *
  32679. * No setter as we it is a shared configuration, you can set the values instead.
  32680. */
  32681. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32682. private _forceWireframe;
  32683. /**
  32684. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32685. */
  32686. forceWireframe: boolean;
  32687. private _forcePointsCloud;
  32688. /**
  32689. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32690. */
  32691. forcePointsCloud: boolean;
  32692. /**
  32693. * Gets or sets the active clipplane 1
  32694. */
  32695. clipPlane: Nullable<Plane>;
  32696. /**
  32697. * Gets or sets the active clipplane 2
  32698. */
  32699. clipPlane2: Nullable<Plane>;
  32700. /**
  32701. * Gets or sets the active clipplane 3
  32702. */
  32703. clipPlane3: Nullable<Plane>;
  32704. /**
  32705. * Gets or sets the active clipplane 4
  32706. */
  32707. clipPlane4: Nullable<Plane>;
  32708. /**
  32709. * Gets or sets a boolean indicating if animations are enabled
  32710. */
  32711. animationsEnabled: boolean;
  32712. private _animationPropertiesOverride;
  32713. /**
  32714. * Gets or sets the animation properties override
  32715. */
  32716. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32717. /**
  32718. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32719. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32720. */
  32721. useConstantAnimationDeltaTime: boolean;
  32722. /**
  32723. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32724. * Please note that it requires to run a ray cast through the scene on every frame
  32725. */
  32726. constantlyUpdateMeshUnderPointer: boolean;
  32727. /**
  32728. * Defines the HTML cursor to use when hovering over interactive elements
  32729. */
  32730. hoverCursor: string;
  32731. /**
  32732. * Defines the HTML default cursor to use (empty by default)
  32733. */
  32734. defaultCursor: string;
  32735. /**
  32736. * This is used to call preventDefault() on pointer down
  32737. * in order to block unwanted artifacts like system double clicks
  32738. */
  32739. preventDefaultOnPointerDown: boolean;
  32740. /**
  32741. * This is used to call preventDefault() on pointer up
  32742. * in order to block unwanted artifacts like system double clicks
  32743. */
  32744. preventDefaultOnPointerUp: boolean;
  32745. /**
  32746. * Gets or sets user defined metadata
  32747. */
  32748. metadata: any;
  32749. /**
  32750. * For internal use only. Please do not use.
  32751. */
  32752. reservedDataStore: any;
  32753. /**
  32754. * Gets the name of the plugin used to load this scene (null by default)
  32755. */
  32756. loadingPluginName: string;
  32757. /**
  32758. * Use this array to add regular expressions used to disable offline support for specific urls
  32759. */
  32760. disableOfflineSupportExceptionRules: RegExp[];
  32761. /**
  32762. * An event triggered when the scene is disposed.
  32763. */
  32764. onDisposeObservable: Observable<Scene>;
  32765. private _onDisposeObserver;
  32766. /** Sets a function to be executed when this scene is disposed. */
  32767. onDispose: () => void;
  32768. /**
  32769. * An event triggered before rendering the scene (right after animations and physics)
  32770. */
  32771. onBeforeRenderObservable: Observable<Scene>;
  32772. private _onBeforeRenderObserver;
  32773. /** Sets a function to be executed before rendering this scene */
  32774. beforeRender: Nullable<() => void>;
  32775. /**
  32776. * An event triggered after rendering the scene
  32777. */
  32778. onAfterRenderObservable: Observable<Scene>;
  32779. /**
  32780. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32781. */
  32782. onAfterRenderCameraObservable: Observable<Camera>;
  32783. private _onAfterRenderObserver;
  32784. /** Sets a function to be executed after rendering this scene */
  32785. afterRender: Nullable<() => void>;
  32786. /**
  32787. * An event triggered before animating the scene
  32788. */
  32789. onBeforeAnimationsObservable: Observable<Scene>;
  32790. /**
  32791. * An event triggered after animations processing
  32792. */
  32793. onAfterAnimationsObservable: Observable<Scene>;
  32794. /**
  32795. * An event triggered before draw calls are ready to be sent
  32796. */
  32797. onBeforeDrawPhaseObservable: Observable<Scene>;
  32798. /**
  32799. * An event triggered after draw calls have been sent
  32800. */
  32801. onAfterDrawPhaseObservable: Observable<Scene>;
  32802. /**
  32803. * An event triggered when the scene is ready
  32804. */
  32805. onReadyObservable: Observable<Scene>;
  32806. /**
  32807. * An event triggered before rendering a camera
  32808. */
  32809. onBeforeCameraRenderObservable: Observable<Camera>;
  32810. private _onBeforeCameraRenderObserver;
  32811. /** Sets a function to be executed before rendering a camera*/
  32812. beforeCameraRender: () => void;
  32813. /**
  32814. * An event triggered after rendering a camera
  32815. */
  32816. onAfterCameraRenderObservable: Observable<Camera>;
  32817. private _onAfterCameraRenderObserver;
  32818. /** Sets a function to be executed after rendering a camera*/
  32819. afterCameraRender: () => void;
  32820. /**
  32821. * An event triggered when active meshes evaluation is about to start
  32822. */
  32823. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32824. /**
  32825. * An event triggered when active meshes evaluation is done
  32826. */
  32827. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32828. /**
  32829. * An event triggered when particles rendering is about to start
  32830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32831. */
  32832. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32833. /**
  32834. * An event triggered when particles rendering is done
  32835. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32836. */
  32837. onAfterParticlesRenderingObservable: Observable<Scene>;
  32838. /**
  32839. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32840. */
  32841. onDataLoadedObservable: Observable<Scene>;
  32842. /**
  32843. * An event triggered when a camera is created
  32844. */
  32845. onNewCameraAddedObservable: Observable<Camera>;
  32846. /**
  32847. * An event triggered when a camera is removed
  32848. */
  32849. onCameraRemovedObservable: Observable<Camera>;
  32850. /**
  32851. * An event triggered when a light is created
  32852. */
  32853. onNewLightAddedObservable: Observable<Light>;
  32854. /**
  32855. * An event triggered when a light is removed
  32856. */
  32857. onLightRemovedObservable: Observable<Light>;
  32858. /**
  32859. * An event triggered when a geometry is created
  32860. */
  32861. onNewGeometryAddedObservable: Observable<Geometry>;
  32862. /**
  32863. * An event triggered when a geometry is removed
  32864. */
  32865. onGeometryRemovedObservable: Observable<Geometry>;
  32866. /**
  32867. * An event triggered when a transform node is created
  32868. */
  32869. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32870. /**
  32871. * An event triggered when a transform node is removed
  32872. */
  32873. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32874. /**
  32875. * An event triggered when a mesh is created
  32876. */
  32877. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32878. /**
  32879. * An event triggered when a mesh is removed
  32880. */
  32881. onMeshRemovedObservable: Observable<AbstractMesh>;
  32882. /**
  32883. * An event triggered when a skeleton is created
  32884. */
  32885. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32886. /**
  32887. * An event triggered when a skeleton is removed
  32888. */
  32889. onSkeletonRemovedObservable: Observable<Skeleton>;
  32890. /**
  32891. * An event triggered when a material is created
  32892. */
  32893. onNewMaterialAddedObservable: Observable<Material>;
  32894. /**
  32895. * An event triggered when a material is removed
  32896. */
  32897. onMaterialRemovedObservable: Observable<Material>;
  32898. /**
  32899. * An event triggered when a texture is created
  32900. */
  32901. onNewTextureAddedObservable: Observable<BaseTexture>;
  32902. /**
  32903. * An event triggered when a texture is removed
  32904. */
  32905. onTextureRemovedObservable: Observable<BaseTexture>;
  32906. /**
  32907. * An event triggered when render targets are about to be rendered
  32908. * Can happen multiple times per frame.
  32909. */
  32910. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32911. /**
  32912. * An event triggered when render targets were rendered.
  32913. * Can happen multiple times per frame.
  32914. */
  32915. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32916. /**
  32917. * An event triggered before calculating deterministic simulation step
  32918. */
  32919. onBeforeStepObservable: Observable<Scene>;
  32920. /**
  32921. * An event triggered after calculating deterministic simulation step
  32922. */
  32923. onAfterStepObservable: Observable<Scene>;
  32924. /**
  32925. * An event triggered when the activeCamera property is updated
  32926. */
  32927. onActiveCameraChanged: Observable<Scene>;
  32928. /**
  32929. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32930. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32931. * 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)
  32932. */
  32933. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32934. /**
  32935. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32937. * 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)
  32938. */
  32939. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32940. /**
  32941. * This Observable will when a mesh has been imported into the scene.
  32942. */
  32943. onMeshImportedObservable: Observable<AbstractMesh>;
  32944. /**
  32945. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32946. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32947. */
  32948. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32949. /** @hidden */
  32950. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32951. /**
  32952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32953. */
  32954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32955. /**
  32956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32957. */
  32958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32959. /**
  32960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32961. */
  32962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32963. /** Callback called when a pointer move is detected */
  32964. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32965. /** Callback called when a pointer down is detected */
  32966. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32967. /** Callback called when a pointer up is detected */
  32968. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32969. /** Callback called when a pointer pick is detected */
  32970. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32971. /**
  32972. * 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).
  32973. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32974. */
  32975. onPrePointerObservable: Observable<PointerInfoPre>;
  32976. /**
  32977. * Observable event triggered each time an input event is received from the rendering canvas
  32978. */
  32979. onPointerObservable: Observable<PointerInfo>;
  32980. /**
  32981. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32982. */
  32983. readonly unTranslatedPointer: Vector2;
  32984. /**
  32985. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32986. */
  32987. static DragMovementThreshold: number;
  32988. /**
  32989. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32990. */
  32991. static LongPressDelay: number;
  32992. /**
  32993. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32994. */
  32995. static DoubleClickDelay: number;
  32996. /** If you need to check double click without raising a single click at first click, enable this flag */
  32997. static ExclusiveDoubleClickMode: boolean;
  32998. /** @hidden */
  32999. _mirroredCameraPosition: Nullable<Vector3>;
  33000. /**
  33001. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33002. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33003. */
  33004. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33005. /**
  33006. * Observable event triggered each time an keyboard event is received from the hosting window
  33007. */
  33008. onKeyboardObservable: Observable<KeyboardInfo>;
  33009. private _useRightHandedSystem;
  33010. /**
  33011. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33012. */
  33013. useRightHandedSystem: boolean;
  33014. private _timeAccumulator;
  33015. private _currentStepId;
  33016. private _currentInternalStep;
  33017. /**
  33018. * Sets the step Id used by deterministic lock step
  33019. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33020. * @param newStepId defines the step Id
  33021. */
  33022. setStepId(newStepId: number): void;
  33023. /**
  33024. * Gets the step Id used by deterministic lock step
  33025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33026. * @returns the step Id
  33027. */
  33028. getStepId(): number;
  33029. /**
  33030. * Gets the internal step used by deterministic lock step
  33031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33032. * @returns the internal step
  33033. */
  33034. getInternalStep(): number;
  33035. private _fogEnabled;
  33036. /**
  33037. * Gets or sets a boolean indicating if fog is enabled on this scene
  33038. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33039. * (Default is true)
  33040. */
  33041. fogEnabled: boolean;
  33042. private _fogMode;
  33043. /**
  33044. * Gets or sets the fog mode to use
  33045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33046. * | mode | value |
  33047. * | --- | --- |
  33048. * | FOGMODE_NONE | 0 |
  33049. * | FOGMODE_EXP | 1 |
  33050. * | FOGMODE_EXP2 | 2 |
  33051. * | FOGMODE_LINEAR | 3 |
  33052. */
  33053. fogMode: number;
  33054. /**
  33055. * Gets or sets the fog color to use
  33056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33057. * (Default is Color3(0.2, 0.2, 0.3))
  33058. */
  33059. fogColor: Color3;
  33060. /**
  33061. * Gets or sets the fog density to use
  33062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33063. * (Default is 0.1)
  33064. */
  33065. fogDensity: number;
  33066. /**
  33067. * Gets or sets the fog start distance to use
  33068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33069. * (Default is 0)
  33070. */
  33071. fogStart: number;
  33072. /**
  33073. * Gets or sets the fog end distance to use
  33074. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33075. * (Default is 1000)
  33076. */
  33077. fogEnd: number;
  33078. private _shadowsEnabled;
  33079. /**
  33080. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33081. */
  33082. shadowsEnabled: boolean;
  33083. private _lightsEnabled;
  33084. /**
  33085. * Gets or sets a boolean indicating if lights are enabled on this scene
  33086. */
  33087. lightsEnabled: boolean;
  33088. /** All of the active cameras added to this scene. */
  33089. activeCameras: Camera[];
  33090. /** @hidden */
  33091. _activeCamera: Nullable<Camera>;
  33092. /** Gets or sets the current active camera */
  33093. activeCamera: Nullable<Camera>;
  33094. private _defaultMaterial;
  33095. /** The default material used on meshes when no material is affected */
  33096. /** The default material used on meshes when no material is affected */
  33097. defaultMaterial: Material;
  33098. private _texturesEnabled;
  33099. /**
  33100. * Gets or sets a boolean indicating if textures are enabled on this scene
  33101. */
  33102. texturesEnabled: boolean;
  33103. /**
  33104. * Gets or sets a boolean indicating if particles are enabled on this scene
  33105. */
  33106. particlesEnabled: boolean;
  33107. /**
  33108. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33109. */
  33110. spritesEnabled: boolean;
  33111. private _skeletonsEnabled;
  33112. /**
  33113. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33114. */
  33115. skeletonsEnabled: boolean;
  33116. /**
  33117. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33118. */
  33119. lensFlaresEnabled: boolean;
  33120. /**
  33121. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33123. */
  33124. collisionsEnabled: boolean;
  33125. private _collisionCoordinator;
  33126. /** @hidden */
  33127. readonly collisionCoordinator: ICollisionCoordinator;
  33128. /**
  33129. * Defines the gravity applied to this scene (used only for collisions)
  33130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33131. */
  33132. gravity: Vector3;
  33133. /**
  33134. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33135. */
  33136. postProcessesEnabled: boolean;
  33137. /**
  33138. * The list of postprocesses added to the scene
  33139. */
  33140. postProcesses: PostProcess[];
  33141. /**
  33142. * Gets the current postprocess manager
  33143. */
  33144. postProcessManager: PostProcessManager;
  33145. /**
  33146. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33147. */
  33148. renderTargetsEnabled: boolean;
  33149. /**
  33150. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33151. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33152. */
  33153. dumpNextRenderTargets: boolean;
  33154. /**
  33155. * The list of user defined render targets added to the scene
  33156. */
  33157. customRenderTargets: RenderTargetTexture[];
  33158. /**
  33159. * Defines if texture loading must be delayed
  33160. * If true, textures will only be loaded when they need to be rendered
  33161. */
  33162. useDelayedTextureLoading: boolean;
  33163. /**
  33164. * Gets the list of meshes imported to the scene through SceneLoader
  33165. */
  33166. importedMeshesFiles: String[];
  33167. /**
  33168. * Gets or sets a boolean indicating if probes are enabled on this scene
  33169. */
  33170. probesEnabled: boolean;
  33171. /**
  33172. * Gets or sets the current offline provider to use to store scene data
  33173. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33174. */
  33175. offlineProvider: IOfflineProvider;
  33176. /**
  33177. * Gets or sets the action manager associated with the scene
  33178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33179. */
  33180. actionManager: AbstractActionManager;
  33181. private _meshesForIntersections;
  33182. /**
  33183. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33184. */
  33185. proceduralTexturesEnabled: boolean;
  33186. private _engine;
  33187. private _totalVertices;
  33188. /** @hidden */
  33189. _activeIndices: PerfCounter;
  33190. /** @hidden */
  33191. _activeParticles: PerfCounter;
  33192. /** @hidden */
  33193. _activeBones: PerfCounter;
  33194. private _animationRatio;
  33195. /** @hidden */
  33196. _animationTimeLast: number;
  33197. /** @hidden */
  33198. _animationTime: number;
  33199. /**
  33200. * Gets or sets a general scale for animation speed
  33201. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33202. */
  33203. animationTimeScale: number;
  33204. /** @hidden */
  33205. _cachedMaterial: Nullable<Material>;
  33206. /** @hidden */
  33207. _cachedEffect: Nullable<Effect>;
  33208. /** @hidden */
  33209. _cachedVisibility: Nullable<number>;
  33210. private _renderId;
  33211. private _frameId;
  33212. private _executeWhenReadyTimeoutId;
  33213. private _intermediateRendering;
  33214. private _viewUpdateFlag;
  33215. private _projectionUpdateFlag;
  33216. /** @hidden */
  33217. _toBeDisposed: Nullable<IDisposable>[];
  33218. private _activeRequests;
  33219. /** @hidden */
  33220. _pendingData: any[];
  33221. private _isDisposed;
  33222. /**
  33223. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33224. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33225. */
  33226. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33227. private _activeMeshes;
  33228. private _processedMaterials;
  33229. private _renderTargets;
  33230. /** @hidden */
  33231. _activeParticleSystems: SmartArray<IParticleSystem>;
  33232. private _activeSkeletons;
  33233. private _softwareSkinnedMeshes;
  33234. private _renderingManager;
  33235. /** @hidden */
  33236. _activeAnimatables: Animatable[];
  33237. private _transformMatrix;
  33238. private _sceneUbo;
  33239. /** @hidden */
  33240. _viewMatrix: Matrix;
  33241. private _projectionMatrix;
  33242. /** @hidden */
  33243. _forcedViewPosition: Nullable<Vector3>;
  33244. /** @hidden */
  33245. _frustumPlanes: Plane[];
  33246. /**
  33247. * Gets the list of frustum planes (built from the active camera)
  33248. */
  33249. readonly frustumPlanes: Plane[];
  33250. /**
  33251. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33252. * This is useful if there are more lights that the maximum simulteanous authorized
  33253. */
  33254. requireLightSorting: boolean;
  33255. /** @hidden */
  33256. readonly useMaterialMeshMap: boolean;
  33257. /** @hidden */
  33258. readonly useClonedMeshhMap: boolean;
  33259. private _externalData;
  33260. private _uid;
  33261. /**
  33262. * @hidden
  33263. * Backing store of defined scene components.
  33264. */
  33265. _components: ISceneComponent[];
  33266. /**
  33267. * @hidden
  33268. * Backing store of defined scene components.
  33269. */
  33270. _serializableComponents: ISceneSerializableComponent[];
  33271. /**
  33272. * List of components to register on the next registration step.
  33273. */
  33274. private _transientComponents;
  33275. /**
  33276. * Registers the transient components if needed.
  33277. */
  33278. private _registerTransientComponents;
  33279. /**
  33280. * @hidden
  33281. * Add a component to the scene.
  33282. * Note that the ccomponent could be registered on th next frame if this is called after
  33283. * the register component stage.
  33284. * @param component Defines the component to add to the scene
  33285. */
  33286. _addComponent(component: ISceneComponent): void;
  33287. /**
  33288. * @hidden
  33289. * Gets a component from the scene.
  33290. * @param name defines the name of the component to retrieve
  33291. * @returns the component or null if not present
  33292. */
  33293. _getComponent(name: string): Nullable<ISceneComponent>;
  33294. /**
  33295. * @hidden
  33296. * Defines the actions happening before camera updates.
  33297. */
  33298. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33299. /**
  33300. * @hidden
  33301. * Defines the actions happening before clear the canvas.
  33302. */
  33303. _beforeClearStage: Stage<SimpleStageAction>;
  33304. /**
  33305. * @hidden
  33306. * Defines the actions when collecting render targets for the frame.
  33307. */
  33308. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33309. /**
  33310. * @hidden
  33311. * Defines the actions happening for one camera in the frame.
  33312. */
  33313. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33314. /**
  33315. * @hidden
  33316. * Defines the actions happening during the per mesh ready checks.
  33317. */
  33318. _isReadyForMeshStage: Stage<MeshStageAction>;
  33319. /**
  33320. * @hidden
  33321. * Defines the actions happening before evaluate active mesh checks.
  33322. */
  33323. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33324. /**
  33325. * @hidden
  33326. * Defines the actions happening during the evaluate sub mesh checks.
  33327. */
  33328. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33329. /**
  33330. * @hidden
  33331. * Defines the actions happening during the active mesh stage.
  33332. */
  33333. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33334. /**
  33335. * @hidden
  33336. * Defines the actions happening during the per camera render target step.
  33337. */
  33338. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33339. /**
  33340. * @hidden
  33341. * Defines the actions happening just before the active camera is drawing.
  33342. */
  33343. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33344. /**
  33345. * @hidden
  33346. * Defines the actions happening just before a render target is drawing.
  33347. */
  33348. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33349. /**
  33350. * @hidden
  33351. * Defines the actions happening just before a rendering group is drawing.
  33352. */
  33353. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33354. /**
  33355. * @hidden
  33356. * Defines the actions happening just before a mesh is drawing.
  33357. */
  33358. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33359. /**
  33360. * @hidden
  33361. * Defines the actions happening just after a mesh has been drawn.
  33362. */
  33363. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33364. /**
  33365. * @hidden
  33366. * Defines the actions happening just after a rendering group has been drawn.
  33367. */
  33368. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33369. /**
  33370. * @hidden
  33371. * Defines the actions happening just after the active camera has been drawn.
  33372. */
  33373. _afterCameraDrawStage: Stage<CameraStageAction>;
  33374. /**
  33375. * @hidden
  33376. * Defines the actions happening just after a render target has been drawn.
  33377. */
  33378. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33379. /**
  33380. * @hidden
  33381. * Defines the actions happening just after rendering all cameras and computing intersections.
  33382. */
  33383. _afterRenderStage: Stage<SimpleStageAction>;
  33384. /**
  33385. * @hidden
  33386. * Defines the actions happening when a pointer move event happens.
  33387. */
  33388. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33389. /**
  33390. * @hidden
  33391. * Defines the actions happening when a pointer down event happens.
  33392. */
  33393. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33394. /**
  33395. * @hidden
  33396. * Defines the actions happening when a pointer up event happens.
  33397. */
  33398. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33399. /**
  33400. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33401. */
  33402. private geometriesByUniqueId;
  33403. /**
  33404. * Creates a new Scene
  33405. * @param engine defines the engine to use to render this scene
  33406. * @param options defines the scene options
  33407. */
  33408. constructor(engine: Engine, options?: SceneOptions);
  33409. /**
  33410. * Gets a string idenfifying the name of the class
  33411. * @returns "Scene" string
  33412. */
  33413. getClassName(): string;
  33414. private _defaultMeshCandidates;
  33415. /**
  33416. * @hidden
  33417. */
  33418. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33419. private _defaultSubMeshCandidates;
  33420. /**
  33421. * @hidden
  33422. */
  33423. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33424. /**
  33425. * Sets the default candidate providers for the scene.
  33426. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33427. * and getCollidingSubMeshCandidates to their default function
  33428. */
  33429. setDefaultCandidateProviders(): void;
  33430. /**
  33431. * Gets the mesh that is currently under the pointer
  33432. */
  33433. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33434. /**
  33435. * Gets or sets the current on-screen X position of the pointer
  33436. */
  33437. pointerX: number;
  33438. /**
  33439. * Gets or sets the current on-screen Y position of the pointer
  33440. */
  33441. pointerY: number;
  33442. /**
  33443. * Gets the cached material (ie. the latest rendered one)
  33444. * @returns the cached material
  33445. */
  33446. getCachedMaterial(): Nullable<Material>;
  33447. /**
  33448. * Gets the cached effect (ie. the latest rendered one)
  33449. * @returns the cached effect
  33450. */
  33451. getCachedEffect(): Nullable<Effect>;
  33452. /**
  33453. * Gets the cached visibility state (ie. the latest rendered one)
  33454. * @returns the cached visibility state
  33455. */
  33456. getCachedVisibility(): Nullable<number>;
  33457. /**
  33458. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33459. * @param material defines the current material
  33460. * @param effect defines the current effect
  33461. * @param visibility defines the current visibility state
  33462. * @returns true if one parameter is not cached
  33463. */
  33464. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33465. /**
  33466. * Gets the engine associated with the scene
  33467. * @returns an Engine
  33468. */
  33469. getEngine(): Engine;
  33470. /**
  33471. * Gets the total number of vertices rendered per frame
  33472. * @returns the total number of vertices rendered per frame
  33473. */
  33474. getTotalVertices(): number;
  33475. /**
  33476. * Gets the performance counter for total vertices
  33477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33478. */
  33479. readonly totalVerticesPerfCounter: PerfCounter;
  33480. /**
  33481. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33482. * @returns the total number of active indices rendered per frame
  33483. */
  33484. getActiveIndices(): number;
  33485. /**
  33486. * Gets the performance counter for active indices
  33487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33488. */
  33489. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33490. /**
  33491. * Gets the total number of active particles rendered per frame
  33492. * @returns the total number of active particles rendered per frame
  33493. */
  33494. getActiveParticles(): number;
  33495. /**
  33496. * Gets the performance counter for active particles
  33497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33498. */
  33499. readonly activeParticlesPerfCounter: PerfCounter;
  33500. /**
  33501. * Gets the total number of active bones rendered per frame
  33502. * @returns the total number of active bones rendered per frame
  33503. */
  33504. getActiveBones(): number;
  33505. /**
  33506. * Gets the performance counter for active bones
  33507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33508. */
  33509. readonly activeBonesPerfCounter: PerfCounter;
  33510. /**
  33511. * Gets the array of active meshes
  33512. * @returns an array of AbstractMesh
  33513. */
  33514. getActiveMeshes(): SmartArray<AbstractMesh>;
  33515. /**
  33516. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33517. * @returns a number
  33518. */
  33519. getAnimationRatio(): number;
  33520. /**
  33521. * Gets an unique Id for the current render phase
  33522. * @returns a number
  33523. */
  33524. getRenderId(): number;
  33525. /**
  33526. * Gets an unique Id for the current frame
  33527. * @returns a number
  33528. */
  33529. getFrameId(): number;
  33530. /** Call this function if you want to manually increment the render Id*/
  33531. incrementRenderId(): void;
  33532. private _createUbo;
  33533. /**
  33534. * Use this method to simulate a pointer move on a mesh
  33535. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33536. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33537. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33538. * @returns the current scene
  33539. */
  33540. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33541. /**
  33542. * Use this method to simulate a pointer down on a mesh
  33543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33546. * @returns the current scene
  33547. */
  33548. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33549. /**
  33550. * Use this method to simulate a pointer up on a mesh
  33551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33554. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33555. * @returns the current scene
  33556. */
  33557. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33558. /**
  33559. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33560. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33561. * @returns true if the pointer was captured
  33562. */
  33563. isPointerCaptured(pointerId?: number): boolean;
  33564. /**
  33565. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33566. * @param attachUp defines if you want to attach events to pointerup
  33567. * @param attachDown defines if you want to attach events to pointerdown
  33568. * @param attachMove defines if you want to attach events to pointermove
  33569. */
  33570. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33571. /** Detaches all event handlers*/
  33572. detachControl(): void;
  33573. /**
  33574. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33575. * Delay loaded resources are not taking in account
  33576. * @return true if all required resources are ready
  33577. */
  33578. isReady(): boolean;
  33579. /** Resets all cached information relative to material (including effect and visibility) */
  33580. resetCachedMaterial(): void;
  33581. /**
  33582. * Registers a function to be called before every frame render
  33583. * @param func defines the function to register
  33584. */
  33585. registerBeforeRender(func: () => void): void;
  33586. /**
  33587. * Unregisters a function called before every frame render
  33588. * @param func defines the function to unregister
  33589. */
  33590. unregisterBeforeRender(func: () => void): void;
  33591. /**
  33592. * Registers a function to be called after every frame render
  33593. * @param func defines the function to register
  33594. */
  33595. registerAfterRender(func: () => void): void;
  33596. /**
  33597. * Unregisters a function called after every frame render
  33598. * @param func defines the function to unregister
  33599. */
  33600. unregisterAfterRender(func: () => void): void;
  33601. private _executeOnceBeforeRender;
  33602. /**
  33603. * The provided function will run before render once and will be disposed afterwards.
  33604. * A timeout delay can be provided so that the function will be executed in N ms.
  33605. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33606. * @param func The function to be executed.
  33607. * @param timeout optional delay in ms
  33608. */
  33609. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33610. /** @hidden */
  33611. _addPendingData(data: any): void;
  33612. /** @hidden */
  33613. _removePendingData(data: any): void;
  33614. /**
  33615. * Returns the number of items waiting to be loaded
  33616. * @returns the number of items waiting to be loaded
  33617. */
  33618. getWaitingItemsCount(): number;
  33619. /**
  33620. * Returns a boolean indicating if the scene is still loading data
  33621. */
  33622. readonly isLoading: boolean;
  33623. /**
  33624. * Registers a function to be executed when the scene is ready
  33625. * @param {Function} func - the function to be executed
  33626. */
  33627. executeWhenReady(func: () => void): void;
  33628. /**
  33629. * Returns a promise that resolves when the scene is ready
  33630. * @returns A promise that resolves when the scene is ready
  33631. */
  33632. whenReadyAsync(): Promise<void>;
  33633. /** @hidden */
  33634. _checkIsReady(): void;
  33635. /**
  33636. * Gets all animatable attached to the scene
  33637. */
  33638. readonly animatables: Animatable[];
  33639. /**
  33640. * Resets the last animation time frame.
  33641. * Useful to override when animations start running when loading a scene for the first time.
  33642. */
  33643. resetLastAnimationTimeFrame(): void;
  33644. /**
  33645. * Gets the current view matrix
  33646. * @returns a Matrix
  33647. */
  33648. getViewMatrix(): Matrix;
  33649. /**
  33650. * Gets the current projection matrix
  33651. * @returns a Matrix
  33652. */
  33653. getProjectionMatrix(): Matrix;
  33654. /**
  33655. * Gets the current transform matrix
  33656. * @returns a Matrix made of View * Projection
  33657. */
  33658. getTransformMatrix(): Matrix;
  33659. /**
  33660. * Sets the current transform matrix
  33661. * @param viewL defines the View matrix to use
  33662. * @param projectionL defines the Projection matrix to use
  33663. * @param viewR defines the right View matrix to use (if provided)
  33664. * @param projectionR defines the right Projection matrix to use (if provided)
  33665. */
  33666. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33667. /**
  33668. * Gets the uniform buffer used to store scene data
  33669. * @returns a UniformBuffer
  33670. */
  33671. getSceneUniformBuffer(): UniformBuffer;
  33672. /**
  33673. * Gets an unique (relatively to the current scene) Id
  33674. * @returns an unique number for the scene
  33675. */
  33676. getUniqueId(): number;
  33677. /**
  33678. * Add a mesh to the list of scene's meshes
  33679. * @param newMesh defines the mesh to add
  33680. * @param recursive if all child meshes should also be added to the scene
  33681. */
  33682. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33683. /**
  33684. * Remove a mesh for the list of scene's meshes
  33685. * @param toRemove defines the mesh to remove
  33686. * @param recursive if all child meshes should also be removed from the scene
  33687. * @returns the index where the mesh was in the mesh list
  33688. */
  33689. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33690. /**
  33691. * Add a transform node to the list of scene's transform nodes
  33692. * @param newTransformNode defines the transform node to add
  33693. */
  33694. addTransformNode(newTransformNode: TransformNode): void;
  33695. /**
  33696. * Remove a transform node for the list of scene's transform nodes
  33697. * @param toRemove defines the transform node to remove
  33698. * @returns the index where the transform node was in the transform node list
  33699. */
  33700. removeTransformNode(toRemove: TransformNode): number;
  33701. /**
  33702. * Remove a skeleton for the list of scene's skeletons
  33703. * @param toRemove defines the skeleton to remove
  33704. * @returns the index where the skeleton was in the skeleton list
  33705. */
  33706. removeSkeleton(toRemove: Skeleton): number;
  33707. /**
  33708. * Remove a morph target for the list of scene's morph targets
  33709. * @param toRemove defines the morph target to remove
  33710. * @returns the index where the morph target was in the morph target list
  33711. */
  33712. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33713. /**
  33714. * Remove a light for the list of scene's lights
  33715. * @param toRemove defines the light to remove
  33716. * @returns the index where the light was in the light list
  33717. */
  33718. removeLight(toRemove: Light): number;
  33719. /**
  33720. * Remove a camera for the list of scene's cameras
  33721. * @param toRemove defines the camera to remove
  33722. * @returns the index where the camera was in the camera list
  33723. */
  33724. removeCamera(toRemove: Camera): number;
  33725. /**
  33726. * Remove a particle system for the list of scene's particle systems
  33727. * @param toRemove defines the particle system to remove
  33728. * @returns the index where the particle system was in the particle system list
  33729. */
  33730. removeParticleSystem(toRemove: IParticleSystem): number;
  33731. /**
  33732. * Remove a animation for the list of scene's animations
  33733. * @param toRemove defines the animation to remove
  33734. * @returns the index where the animation was in the animation list
  33735. */
  33736. removeAnimation(toRemove: Animation): number;
  33737. /**
  33738. * Will stop the animation of the given target
  33739. * @param target - the target
  33740. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33741. * @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)
  33742. */
  33743. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33744. /**
  33745. * Removes the given animation group from this scene.
  33746. * @param toRemove The animation group to remove
  33747. * @returns The index of the removed animation group
  33748. */
  33749. removeAnimationGroup(toRemove: AnimationGroup): number;
  33750. /**
  33751. * Removes the given multi-material from this scene.
  33752. * @param toRemove The multi-material to remove
  33753. * @returns The index of the removed multi-material
  33754. */
  33755. removeMultiMaterial(toRemove: MultiMaterial): number;
  33756. /**
  33757. * Removes the given material from this scene.
  33758. * @param toRemove The material to remove
  33759. * @returns The index of the removed material
  33760. */
  33761. removeMaterial(toRemove: Material): number;
  33762. /**
  33763. * Removes the given action manager from this scene.
  33764. * @param toRemove The action manager to remove
  33765. * @returns The index of the removed action manager
  33766. */
  33767. removeActionManager(toRemove: AbstractActionManager): number;
  33768. /**
  33769. * Removes the given texture from this scene.
  33770. * @param toRemove The texture to remove
  33771. * @returns The index of the removed texture
  33772. */
  33773. removeTexture(toRemove: BaseTexture): number;
  33774. /**
  33775. * Adds the given light to this scene
  33776. * @param newLight The light to add
  33777. */
  33778. addLight(newLight: Light): void;
  33779. /**
  33780. * Sorts the list list based on light priorities
  33781. */
  33782. sortLightsByPriority(): void;
  33783. /**
  33784. * Adds the given camera to this scene
  33785. * @param newCamera The camera to add
  33786. */
  33787. addCamera(newCamera: Camera): void;
  33788. /**
  33789. * Adds the given skeleton to this scene
  33790. * @param newSkeleton The skeleton to add
  33791. */
  33792. addSkeleton(newSkeleton: Skeleton): void;
  33793. /**
  33794. * Adds the given particle system to this scene
  33795. * @param newParticleSystem The particle system to add
  33796. */
  33797. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33798. /**
  33799. * Adds the given animation to this scene
  33800. * @param newAnimation The animation to add
  33801. */
  33802. addAnimation(newAnimation: Animation): void;
  33803. /**
  33804. * Adds the given animation group to this scene.
  33805. * @param newAnimationGroup The animation group to add
  33806. */
  33807. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33808. /**
  33809. * Adds the given multi-material to this scene
  33810. * @param newMultiMaterial The multi-material to add
  33811. */
  33812. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33813. /**
  33814. * Adds the given material to this scene
  33815. * @param newMaterial The material to add
  33816. */
  33817. addMaterial(newMaterial: Material): void;
  33818. /**
  33819. * Adds the given morph target to this scene
  33820. * @param newMorphTargetManager The morph target to add
  33821. */
  33822. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33823. /**
  33824. * Adds the given geometry to this scene
  33825. * @param newGeometry The geometry to add
  33826. */
  33827. addGeometry(newGeometry: Geometry): void;
  33828. /**
  33829. * Adds the given action manager to this scene
  33830. * @param newActionManager The action manager to add
  33831. */
  33832. addActionManager(newActionManager: AbstractActionManager): void;
  33833. /**
  33834. * Adds the given texture to this scene.
  33835. * @param newTexture The texture to add
  33836. */
  33837. addTexture(newTexture: BaseTexture): void;
  33838. /**
  33839. * Switch active camera
  33840. * @param newCamera defines the new active camera
  33841. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33842. */
  33843. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33844. /**
  33845. * sets the active camera of the scene using its ID
  33846. * @param id defines the camera's ID
  33847. * @return the new active camera or null if none found.
  33848. */
  33849. setActiveCameraByID(id: string): Nullable<Camera>;
  33850. /**
  33851. * sets the active camera of the scene using its name
  33852. * @param name defines the camera's name
  33853. * @returns the new active camera or null if none found.
  33854. */
  33855. setActiveCameraByName(name: string): Nullable<Camera>;
  33856. /**
  33857. * get an animation group using its name
  33858. * @param name defines the material's name
  33859. * @return the animation group or null if none found.
  33860. */
  33861. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33862. /**
  33863. * Get a material using its unique id
  33864. * @param uniqueId defines the material's unique id
  33865. * @return the material or null if none found.
  33866. */
  33867. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33868. /**
  33869. * get a material using its id
  33870. * @param id defines the material's ID
  33871. * @return the material or null if none found.
  33872. */
  33873. getMaterialByID(id: string): Nullable<Material>;
  33874. /**
  33875. * Gets a the last added material using a given id
  33876. * @param id defines the material's ID
  33877. * @return the last material with the given id or null if none found.
  33878. */
  33879. getLastMaterialByID(id: string): Nullable<Material>;
  33880. /**
  33881. * Gets a material using its name
  33882. * @param name defines the material's name
  33883. * @return the material or null if none found.
  33884. */
  33885. getMaterialByName(name: string): Nullable<Material>;
  33886. /**
  33887. * Get a texture using its unique id
  33888. * @param uniqueId defines the texture's unique id
  33889. * @return the texture or null if none found.
  33890. */
  33891. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33892. /**
  33893. * Gets a camera using its id
  33894. * @param id defines the id to look for
  33895. * @returns the camera or null if not found
  33896. */
  33897. getCameraByID(id: string): Nullable<Camera>;
  33898. /**
  33899. * Gets a camera using its unique id
  33900. * @param uniqueId defines the unique id to look for
  33901. * @returns the camera or null if not found
  33902. */
  33903. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33904. /**
  33905. * Gets a camera using its name
  33906. * @param name defines the camera's name
  33907. * @return the camera or null if none found.
  33908. */
  33909. getCameraByName(name: string): Nullable<Camera>;
  33910. /**
  33911. * Gets a bone using its id
  33912. * @param id defines the bone's id
  33913. * @return the bone or null if not found
  33914. */
  33915. getBoneByID(id: string): Nullable<Bone>;
  33916. /**
  33917. * Gets a bone using its id
  33918. * @param name defines the bone's name
  33919. * @return the bone or null if not found
  33920. */
  33921. getBoneByName(name: string): Nullable<Bone>;
  33922. /**
  33923. * Gets a light node using its name
  33924. * @param name defines the the light's name
  33925. * @return the light or null if none found.
  33926. */
  33927. getLightByName(name: string): Nullable<Light>;
  33928. /**
  33929. * Gets a light node using its id
  33930. * @param id defines the light's id
  33931. * @return the light or null if none found.
  33932. */
  33933. getLightByID(id: string): Nullable<Light>;
  33934. /**
  33935. * Gets a light node using its scene-generated unique ID
  33936. * @param uniqueId defines the light's unique id
  33937. * @return the light or null if none found.
  33938. */
  33939. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33940. /**
  33941. * Gets a particle system by id
  33942. * @param id defines the particle system id
  33943. * @return the corresponding system or null if none found
  33944. */
  33945. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33946. /**
  33947. * Gets a geometry using its ID
  33948. * @param id defines the geometry's id
  33949. * @return the geometry or null if none found.
  33950. */
  33951. getGeometryByID(id: string): Nullable<Geometry>;
  33952. private _getGeometryByUniqueID;
  33953. /**
  33954. * Add a new geometry to this scene
  33955. * @param geometry defines the geometry to be added to the scene.
  33956. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33957. * @return a boolean defining if the geometry was added or not
  33958. */
  33959. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33960. /**
  33961. * Removes an existing geometry
  33962. * @param geometry defines the geometry to be removed from the scene
  33963. * @return a boolean defining if the geometry was removed or not
  33964. */
  33965. removeGeometry(geometry: Geometry): boolean;
  33966. /**
  33967. * Gets the list of geometries attached to the scene
  33968. * @returns an array of Geometry
  33969. */
  33970. getGeometries(): Geometry[];
  33971. /**
  33972. * Gets the first added mesh found of a given ID
  33973. * @param id defines the id to search for
  33974. * @return the mesh found or null if not found at all
  33975. */
  33976. getMeshByID(id: string): Nullable<AbstractMesh>;
  33977. /**
  33978. * Gets a list of meshes using their id
  33979. * @param id defines the id to search for
  33980. * @returns a list of meshes
  33981. */
  33982. getMeshesByID(id: string): Array<AbstractMesh>;
  33983. /**
  33984. * Gets the first added transform node found of a given ID
  33985. * @param id defines the id to search for
  33986. * @return the found transform node or null if not found at all.
  33987. */
  33988. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33989. /**
  33990. * Gets a transform node with its auto-generated unique id
  33991. * @param uniqueId efines the unique id to search for
  33992. * @return the found transform node or null if not found at all.
  33993. */
  33994. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33995. /**
  33996. * Gets a list of transform nodes using their id
  33997. * @param id defines the id to search for
  33998. * @returns a list of transform nodes
  33999. */
  34000. getTransformNodesByID(id: string): Array<TransformNode>;
  34001. /**
  34002. * Gets a mesh with its auto-generated unique id
  34003. * @param uniqueId defines the unique id to search for
  34004. * @return the found mesh or null if not found at all.
  34005. */
  34006. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34007. /**
  34008. * Gets a the last added mesh using a given id
  34009. * @param id defines the id to search for
  34010. * @return the found mesh or null if not found at all.
  34011. */
  34012. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34013. /**
  34014. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34015. * @param id defines the id to search for
  34016. * @return the found node or null if not found at all
  34017. */
  34018. getLastEntryByID(id: string): Nullable<Node>;
  34019. /**
  34020. * Gets a node (Mesh, Camera, Light) using a given id
  34021. * @param id defines the id to search for
  34022. * @return the found node or null if not found at all
  34023. */
  34024. getNodeByID(id: string): Nullable<Node>;
  34025. /**
  34026. * Gets a node (Mesh, Camera, Light) using a given name
  34027. * @param name defines the name to search for
  34028. * @return the found node or null if not found at all.
  34029. */
  34030. getNodeByName(name: string): Nullable<Node>;
  34031. /**
  34032. * Gets a mesh using a given name
  34033. * @param name defines the name to search for
  34034. * @return the found mesh or null if not found at all.
  34035. */
  34036. getMeshByName(name: string): Nullable<AbstractMesh>;
  34037. /**
  34038. * Gets a transform node using a given name
  34039. * @param name defines the name to search for
  34040. * @return the found transform node or null if not found at all.
  34041. */
  34042. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34043. /**
  34044. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34045. * @param id defines the id to search for
  34046. * @return the found skeleton or null if not found at all.
  34047. */
  34048. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34049. /**
  34050. * Gets a skeleton using a given auto generated unique id
  34051. * @param uniqueId defines the unique id to search for
  34052. * @return the found skeleton or null if not found at all.
  34053. */
  34054. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34055. /**
  34056. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34057. * @param id defines the id to search for
  34058. * @return the found skeleton or null if not found at all.
  34059. */
  34060. getSkeletonById(id: string): Nullable<Skeleton>;
  34061. /**
  34062. * Gets a skeleton using a given name
  34063. * @param name defines the name to search for
  34064. * @return the found skeleton or null if not found at all.
  34065. */
  34066. getSkeletonByName(name: string): Nullable<Skeleton>;
  34067. /**
  34068. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34069. * @param id defines the id to search for
  34070. * @return the found morph target manager or null if not found at all.
  34071. */
  34072. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34073. /**
  34074. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34075. * @param id defines the id to search for
  34076. * @return the found morph target or null if not found at all.
  34077. */
  34078. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34079. /**
  34080. * Gets a boolean indicating if the given mesh is active
  34081. * @param mesh defines the mesh to look for
  34082. * @returns true if the mesh is in the active list
  34083. */
  34084. isActiveMesh(mesh: AbstractMesh): boolean;
  34085. /**
  34086. * Return a unique id as a string which can serve as an identifier for the scene
  34087. */
  34088. readonly uid: string;
  34089. /**
  34090. * Add an externaly attached data from its key.
  34091. * This method call will fail and return false, if such key already exists.
  34092. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34093. * @param key the unique key that identifies the data
  34094. * @param data the data object to associate to the key for this Engine instance
  34095. * @return true if no such key were already present and the data was added successfully, false otherwise
  34096. */
  34097. addExternalData<T>(key: string, data: T): boolean;
  34098. /**
  34099. * Get an externaly attached data from its key
  34100. * @param key the unique key that identifies the data
  34101. * @return the associated data, if present (can be null), or undefined if not present
  34102. */
  34103. getExternalData<T>(key: string): Nullable<T>;
  34104. /**
  34105. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34106. * @param key the unique key that identifies the data
  34107. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34108. * @return the associated data, can be null if the factory returned null.
  34109. */
  34110. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34111. /**
  34112. * Remove an externaly attached data from the Engine instance
  34113. * @param key the unique key that identifies the data
  34114. * @return true if the data was successfully removed, false if it doesn't exist
  34115. */
  34116. removeExternalData(key: string): boolean;
  34117. private _evaluateSubMesh;
  34118. /**
  34119. * Clear the processed materials smart array preventing retention point in material dispose.
  34120. */
  34121. freeProcessedMaterials(): void;
  34122. private _preventFreeActiveMeshesAndRenderingGroups;
  34123. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34124. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34125. * when disposing several meshes in a row or a hierarchy of meshes.
  34126. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34127. */
  34128. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34129. /**
  34130. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34131. */
  34132. freeActiveMeshes(): void;
  34133. /**
  34134. * Clear the info related to rendering groups preventing retention points during dispose.
  34135. */
  34136. freeRenderingGroups(): void;
  34137. /** @hidden */
  34138. _isInIntermediateRendering(): boolean;
  34139. /**
  34140. * Lambda returning the list of potentially active meshes.
  34141. */
  34142. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34143. /**
  34144. * Lambda returning the list of potentially active sub meshes.
  34145. */
  34146. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34147. /**
  34148. * Lambda returning the list of potentially intersecting sub meshes.
  34149. */
  34150. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34151. /**
  34152. * Lambda returning the list of potentially colliding sub meshes.
  34153. */
  34154. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34155. private _activeMeshesFrozen;
  34156. /**
  34157. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34158. * @returns the current scene
  34159. */
  34160. freezeActiveMeshes(): Scene;
  34161. /**
  34162. * Use this function to restart evaluating active meshes on every frame
  34163. * @returns the current scene
  34164. */
  34165. unfreezeActiveMeshes(): Scene;
  34166. private _evaluateActiveMeshes;
  34167. private _activeMesh;
  34168. /**
  34169. * Update the transform matrix to update from the current active camera
  34170. * @param force defines a boolean used to force the update even if cache is up to date
  34171. */
  34172. updateTransformMatrix(force?: boolean): void;
  34173. private _bindFrameBuffer;
  34174. /** @hidden */
  34175. _allowPostProcessClearColor: boolean;
  34176. /** @hidden */
  34177. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34178. private _processSubCameras;
  34179. private _checkIntersections;
  34180. /** @hidden */
  34181. _advancePhysicsEngineStep(step: number): void;
  34182. /**
  34183. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34184. */
  34185. getDeterministicFrameTime: () => number;
  34186. /** @hidden */
  34187. _animate(): void;
  34188. /** Execute all animations (for a frame) */
  34189. animate(): void;
  34190. /**
  34191. * Render the scene
  34192. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34193. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34194. */
  34195. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34196. /**
  34197. * Freeze all materials
  34198. * A frozen material will not be updatable but should be faster to render
  34199. */
  34200. freezeMaterials(): void;
  34201. /**
  34202. * Unfreeze all materials
  34203. * A frozen material will not be updatable but should be faster to render
  34204. */
  34205. unfreezeMaterials(): void;
  34206. /**
  34207. * Releases all held ressources
  34208. */
  34209. dispose(): void;
  34210. /**
  34211. * Gets if the scene is already disposed
  34212. */
  34213. readonly isDisposed: boolean;
  34214. /**
  34215. * Call this function to reduce memory footprint of the scene.
  34216. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34217. */
  34218. clearCachedVertexData(): void;
  34219. /**
  34220. * This function will remove the local cached buffer data from texture.
  34221. * It will save memory but will prevent the texture from being rebuilt
  34222. */
  34223. cleanCachedTextureBuffer(): void;
  34224. /**
  34225. * Get the world extend vectors with an optional filter
  34226. *
  34227. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34228. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34229. */
  34230. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34231. min: Vector3;
  34232. max: Vector3;
  34233. };
  34234. /**
  34235. * Creates a ray that can be used to pick in the scene
  34236. * @param x defines the x coordinate of the origin (on-screen)
  34237. * @param y defines the y coordinate of the origin (on-screen)
  34238. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34239. * @param camera defines the camera to use for the picking
  34240. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34241. * @returns a Ray
  34242. */
  34243. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34244. /**
  34245. * Creates a ray that can be used to pick in the scene
  34246. * @param x defines the x coordinate of the origin (on-screen)
  34247. * @param y defines the y coordinate of the origin (on-screen)
  34248. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34249. * @param result defines the ray where to store the picking ray
  34250. * @param camera defines the camera to use for the picking
  34251. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34252. * @returns the current scene
  34253. */
  34254. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34255. /**
  34256. * Creates a ray that can be used to pick in the scene
  34257. * @param x defines the x coordinate of the origin (on-screen)
  34258. * @param y defines the y coordinate of the origin (on-screen)
  34259. * @param camera defines the camera to use for the picking
  34260. * @returns a Ray
  34261. */
  34262. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34263. /**
  34264. * Creates a ray that can be used to pick in the scene
  34265. * @param x defines the x coordinate of the origin (on-screen)
  34266. * @param y defines the y coordinate of the origin (on-screen)
  34267. * @param result defines the ray where to store the picking ray
  34268. * @param camera defines the camera to use for the picking
  34269. * @returns the current scene
  34270. */
  34271. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34272. /** Launch a ray to try to pick a mesh in the scene
  34273. * @param x position on screen
  34274. * @param y position on screen
  34275. * @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
  34276. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34277. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34279. * @returns a PickingInfo
  34280. */
  34281. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34282. /** Use the given ray to pick a mesh in the scene
  34283. * @param ray The ray to use to pick meshes
  34284. * @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
  34285. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34287. * @returns a PickingInfo
  34288. */
  34289. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34290. /**
  34291. * Launch a ray to try to pick a mesh in the scene
  34292. * @param x X position on screen
  34293. * @param y Y position on screen
  34294. * @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
  34295. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34296. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34297. * @returns an array of PickingInfo
  34298. */
  34299. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34300. /**
  34301. * Launch a ray to try to pick a mesh in the scene
  34302. * @param ray Ray to use
  34303. * @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
  34304. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34305. * @returns an array of PickingInfo
  34306. */
  34307. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34308. /**
  34309. * Force the value of meshUnderPointer
  34310. * @param mesh defines the mesh to use
  34311. */
  34312. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34313. /**
  34314. * Gets the mesh under the pointer
  34315. * @returns a Mesh or null if no mesh is under the pointer
  34316. */
  34317. getPointerOverMesh(): Nullable<AbstractMesh>;
  34318. /** @hidden */
  34319. _rebuildGeometries(): void;
  34320. /** @hidden */
  34321. _rebuildTextures(): void;
  34322. private _getByTags;
  34323. /**
  34324. * Get a list of meshes by tags
  34325. * @param tagsQuery defines the tags query to use
  34326. * @param forEach defines a predicate used to filter results
  34327. * @returns an array of Mesh
  34328. */
  34329. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34330. /**
  34331. * Get a list of cameras by tags
  34332. * @param tagsQuery defines the tags query to use
  34333. * @param forEach defines a predicate used to filter results
  34334. * @returns an array of Camera
  34335. */
  34336. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34337. /**
  34338. * Get a list of lights by tags
  34339. * @param tagsQuery defines the tags query to use
  34340. * @param forEach defines a predicate used to filter results
  34341. * @returns an array of Light
  34342. */
  34343. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34344. /**
  34345. * Get a list of materials by tags
  34346. * @param tagsQuery defines the tags query to use
  34347. * @param forEach defines a predicate used to filter results
  34348. * @returns an array of Material
  34349. */
  34350. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34351. /**
  34352. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34353. * This allowed control for front to back rendering or reversly depending of the special needs.
  34354. *
  34355. * @param renderingGroupId The rendering group id corresponding to its index
  34356. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34357. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34358. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34359. */
  34360. 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;
  34361. /**
  34362. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34363. *
  34364. * @param renderingGroupId The rendering group id corresponding to its index
  34365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34366. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34367. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34368. */
  34369. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34370. /**
  34371. * Gets the current auto clear configuration for one rendering group of the rendering
  34372. * manager.
  34373. * @param index the rendering group index to get the information for
  34374. * @returns The auto clear setup for the requested rendering group
  34375. */
  34376. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34377. private _blockMaterialDirtyMechanism;
  34378. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34379. blockMaterialDirtyMechanism: boolean;
  34380. /**
  34381. * Will flag all materials as dirty to trigger new shader compilation
  34382. * @param flag defines the flag used to specify which material part must be marked as dirty
  34383. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34384. */
  34385. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34386. /** @hidden */
  34387. _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;
  34388. /** @hidden */
  34389. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34390. }
  34391. }
  34392. declare module BABYLON {
  34393. /**
  34394. * Set of assets to keep when moving a scene into an asset container.
  34395. */
  34396. export class KeepAssets extends AbstractScene {
  34397. }
  34398. /**
  34399. * Container with a set of assets that can be added or removed from a scene.
  34400. */
  34401. export class AssetContainer extends AbstractScene {
  34402. /**
  34403. * The scene the AssetContainer belongs to.
  34404. */
  34405. scene: Scene;
  34406. /**
  34407. * Instantiates an AssetContainer.
  34408. * @param scene The scene the AssetContainer belongs to.
  34409. */
  34410. constructor(scene: Scene);
  34411. /**
  34412. * Adds all the assets from the container to the scene.
  34413. */
  34414. addAllToScene(): void;
  34415. /**
  34416. * Removes all the assets in the container from the scene
  34417. */
  34418. removeAllFromScene(): void;
  34419. /**
  34420. * Disposes all the assets in the container
  34421. */
  34422. dispose(): void;
  34423. private _moveAssets;
  34424. /**
  34425. * Removes all the assets contained in the scene and adds them to the container.
  34426. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34427. */
  34428. moveAllFromScene(keepAssets?: KeepAssets): void;
  34429. /**
  34430. * 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.
  34431. * @returns the root mesh
  34432. */
  34433. createRootMesh(): Mesh;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. /**
  34438. * Defines how the parser contract is defined.
  34439. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34440. */
  34441. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34442. /**
  34443. * Defines how the individual parser contract is defined.
  34444. * These parser can parse an individual asset
  34445. */
  34446. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34447. /**
  34448. * Base class of the scene acting as a container for the different elements composing a scene.
  34449. * This class is dynamically extended by the different components of the scene increasing
  34450. * flexibility and reducing coupling
  34451. */
  34452. export abstract class AbstractScene {
  34453. /**
  34454. * Stores the list of available parsers in the application.
  34455. */
  34456. private static _BabylonFileParsers;
  34457. /**
  34458. * Stores the list of available individual parsers in the application.
  34459. */
  34460. private static _IndividualBabylonFileParsers;
  34461. /**
  34462. * Adds a parser in the list of available ones
  34463. * @param name Defines the name of the parser
  34464. * @param parser Defines the parser to add
  34465. */
  34466. static AddParser(name: string, parser: BabylonFileParser): void;
  34467. /**
  34468. * Gets a general parser from the list of avaialble ones
  34469. * @param name Defines the name of the parser
  34470. * @returns the requested parser or null
  34471. */
  34472. static GetParser(name: string): Nullable<BabylonFileParser>;
  34473. /**
  34474. * Adds n individual parser in the list of available ones
  34475. * @param name Defines the name of the parser
  34476. * @param parser Defines the parser to add
  34477. */
  34478. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34479. /**
  34480. * Gets an individual parser from the list of avaialble ones
  34481. * @param name Defines the name of the parser
  34482. * @returns the requested parser or null
  34483. */
  34484. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34485. /**
  34486. * Parser json data and populate both a scene and its associated container object
  34487. * @param jsonData Defines the data to parse
  34488. * @param scene Defines the scene to parse the data for
  34489. * @param container Defines the container attached to the parsing sequence
  34490. * @param rootUrl Defines the root url of the data
  34491. */
  34492. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34493. /**
  34494. * Gets the list of root nodes (ie. nodes with no parent)
  34495. */
  34496. rootNodes: Node[];
  34497. /** All of the cameras added to this scene
  34498. * @see http://doc.babylonjs.com/babylon101/cameras
  34499. */
  34500. cameras: Camera[];
  34501. /**
  34502. * All of the lights added to this scene
  34503. * @see http://doc.babylonjs.com/babylon101/lights
  34504. */
  34505. lights: Light[];
  34506. /**
  34507. * All of the (abstract) meshes added to this scene
  34508. */
  34509. meshes: AbstractMesh[];
  34510. /**
  34511. * The list of skeletons added to the scene
  34512. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34513. */
  34514. skeletons: Skeleton[];
  34515. /**
  34516. * All of the particle systems added to this scene
  34517. * @see http://doc.babylonjs.com/babylon101/particles
  34518. */
  34519. particleSystems: IParticleSystem[];
  34520. /**
  34521. * Gets a list of Animations associated with the scene
  34522. */
  34523. animations: Animation[];
  34524. /**
  34525. * All of the animation groups added to this scene
  34526. * @see http://doc.babylonjs.com/how_to/group
  34527. */
  34528. animationGroups: AnimationGroup[];
  34529. /**
  34530. * All of the multi-materials added to this scene
  34531. * @see http://doc.babylonjs.com/how_to/multi_materials
  34532. */
  34533. multiMaterials: MultiMaterial[];
  34534. /**
  34535. * All of the materials added to this scene
  34536. * In the context of a Scene, it is not supposed to be modified manually.
  34537. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34538. * Note also that the order of the Material wihin the array is not significant and might change.
  34539. * @see http://doc.babylonjs.com/babylon101/materials
  34540. */
  34541. materials: Material[];
  34542. /**
  34543. * The list of morph target managers added to the scene
  34544. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34545. */
  34546. morphTargetManagers: MorphTargetManager[];
  34547. /**
  34548. * The list of geometries used in the scene.
  34549. */
  34550. geometries: Geometry[];
  34551. /**
  34552. * All of the tranform nodes added to this scene
  34553. * In the context of a Scene, it is not supposed to be modified manually.
  34554. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34555. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34556. * @see http://doc.babylonjs.com/how_to/transformnode
  34557. */
  34558. transformNodes: TransformNode[];
  34559. /**
  34560. * ActionManagers available on the scene.
  34561. */
  34562. actionManagers: AbstractActionManager[];
  34563. /**
  34564. * Textures to keep.
  34565. */
  34566. textures: BaseTexture[];
  34567. /**
  34568. * Environment texture for the scene
  34569. */
  34570. environmentTexture: Nullable<BaseTexture>;
  34571. }
  34572. }
  34573. declare module BABYLON {
  34574. /**
  34575. * Interface used to define options for Sound class
  34576. */
  34577. export interface ISoundOptions {
  34578. /**
  34579. * Does the sound autoplay once loaded.
  34580. */
  34581. autoplay?: boolean;
  34582. /**
  34583. * Does the sound loop after it finishes playing once.
  34584. */
  34585. loop?: boolean;
  34586. /**
  34587. * Sound's volume
  34588. */
  34589. volume?: number;
  34590. /**
  34591. * Is it a spatial sound?
  34592. */
  34593. spatialSound?: boolean;
  34594. /**
  34595. * Maximum distance to hear that sound
  34596. */
  34597. maxDistance?: number;
  34598. /**
  34599. * Uses user defined attenuation function
  34600. */
  34601. useCustomAttenuation?: boolean;
  34602. /**
  34603. * Define the roll off factor of spatial sounds.
  34604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34605. */
  34606. rolloffFactor?: number;
  34607. /**
  34608. * Define the reference distance the sound should be heard perfectly.
  34609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34610. */
  34611. refDistance?: number;
  34612. /**
  34613. * Define the distance attenuation model the sound will follow.
  34614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34615. */
  34616. distanceModel?: string;
  34617. /**
  34618. * Defines the playback speed (1 by default)
  34619. */
  34620. playbackRate?: number;
  34621. /**
  34622. * Defines if the sound is from a streaming source
  34623. */
  34624. streaming?: boolean;
  34625. /**
  34626. * Defines an optional length (in seconds) inside the sound file
  34627. */
  34628. length?: number;
  34629. /**
  34630. * Defines an optional offset (in seconds) inside the sound file
  34631. */
  34632. offset?: number;
  34633. /**
  34634. * If true, URLs will not be required to state the audio file codec to use.
  34635. */
  34636. skipCodecCheck?: boolean;
  34637. }
  34638. /**
  34639. * Defines a sound that can be played in the application.
  34640. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34642. */
  34643. export class Sound {
  34644. /**
  34645. * The name of the sound in the scene.
  34646. */
  34647. name: string;
  34648. /**
  34649. * Does the sound autoplay once loaded.
  34650. */
  34651. autoplay: boolean;
  34652. /**
  34653. * Does the sound loop after it finishes playing once.
  34654. */
  34655. loop: boolean;
  34656. /**
  34657. * Does the sound use a custom attenuation curve to simulate the falloff
  34658. * happening when the source gets further away from the camera.
  34659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34660. */
  34661. useCustomAttenuation: boolean;
  34662. /**
  34663. * The sound track id this sound belongs to.
  34664. */
  34665. soundTrackId: number;
  34666. /**
  34667. * Is this sound currently played.
  34668. */
  34669. isPlaying: boolean;
  34670. /**
  34671. * Is this sound currently paused.
  34672. */
  34673. isPaused: boolean;
  34674. /**
  34675. * Does this sound enables spatial sound.
  34676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34677. */
  34678. spatialSound: boolean;
  34679. /**
  34680. * Define the reference distance the sound should be heard perfectly.
  34681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34682. */
  34683. refDistance: number;
  34684. /**
  34685. * Define the roll off factor of spatial sounds.
  34686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34687. */
  34688. rolloffFactor: number;
  34689. /**
  34690. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34692. */
  34693. maxDistance: number;
  34694. /**
  34695. * Define the distance attenuation model the sound will follow.
  34696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34697. */
  34698. distanceModel: string;
  34699. /**
  34700. * @hidden
  34701. * Back Compat
  34702. **/
  34703. onended: () => any;
  34704. /**
  34705. * Observable event when the current playing sound finishes.
  34706. */
  34707. onEndedObservable: Observable<Sound>;
  34708. private _panningModel;
  34709. private _playbackRate;
  34710. private _streaming;
  34711. private _startTime;
  34712. private _startOffset;
  34713. private _position;
  34714. /** @hidden */
  34715. _positionInEmitterSpace: boolean;
  34716. private _localDirection;
  34717. private _volume;
  34718. private _isReadyToPlay;
  34719. private _isDirectional;
  34720. private _readyToPlayCallback;
  34721. private _audioBuffer;
  34722. private _soundSource;
  34723. private _streamingSource;
  34724. private _soundPanner;
  34725. private _soundGain;
  34726. private _inputAudioNode;
  34727. private _outputAudioNode;
  34728. private _coneInnerAngle;
  34729. private _coneOuterAngle;
  34730. private _coneOuterGain;
  34731. private _scene;
  34732. private _connectedTransformNode;
  34733. private _customAttenuationFunction;
  34734. private _registerFunc;
  34735. private _isOutputConnected;
  34736. private _htmlAudioElement;
  34737. private _urlType;
  34738. private _length?;
  34739. private _offset?;
  34740. /** @hidden */
  34741. static _SceneComponentInitialization: (scene: Scene) => void;
  34742. /**
  34743. * Create a sound and attach it to a scene
  34744. * @param name Name of your sound
  34745. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34746. * @param scene defines the scene the sound belongs to
  34747. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34748. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34749. */
  34750. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34751. /**
  34752. * Release the sound and its associated resources
  34753. */
  34754. dispose(): void;
  34755. /**
  34756. * Gets if the sounds is ready to be played or not.
  34757. * @returns true if ready, otherwise false
  34758. */
  34759. isReady(): boolean;
  34760. private _soundLoaded;
  34761. /**
  34762. * Sets the data of the sound from an audiobuffer
  34763. * @param audioBuffer The audioBuffer containing the data
  34764. */
  34765. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34766. /**
  34767. * Updates the current sounds options such as maxdistance, loop...
  34768. * @param options A JSON object containing values named as the object properties
  34769. */
  34770. updateOptions(options: ISoundOptions): void;
  34771. private _createSpatialParameters;
  34772. private _updateSpatialParameters;
  34773. /**
  34774. * Switch the panning model to HRTF:
  34775. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34777. */
  34778. switchPanningModelToHRTF(): void;
  34779. /**
  34780. * Switch the panning model to Equal Power:
  34781. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34783. */
  34784. switchPanningModelToEqualPower(): void;
  34785. private _switchPanningModel;
  34786. /**
  34787. * Connect this sound to a sound track audio node like gain...
  34788. * @param soundTrackAudioNode the sound track audio node to connect to
  34789. */
  34790. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34791. /**
  34792. * Transform this sound into a directional source
  34793. * @param coneInnerAngle Size of the inner cone in degree
  34794. * @param coneOuterAngle Size of the outer cone in degree
  34795. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34796. */
  34797. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34798. /**
  34799. * Gets or sets the inner angle for the directional cone.
  34800. */
  34801. /**
  34802. * Gets or sets the inner angle for the directional cone.
  34803. */
  34804. directionalConeInnerAngle: number;
  34805. /**
  34806. * Gets or sets the outer angle for the directional cone.
  34807. */
  34808. /**
  34809. * Gets or sets the outer angle for the directional cone.
  34810. */
  34811. directionalConeOuterAngle: number;
  34812. /**
  34813. * Sets the position of the emitter if spatial sound is enabled
  34814. * @param newPosition Defines the new posisiton
  34815. */
  34816. setPosition(newPosition: Vector3): void;
  34817. /**
  34818. * Sets the local direction of the emitter if spatial sound is enabled
  34819. * @param newLocalDirection Defines the new local direction
  34820. */
  34821. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34822. private _updateDirection;
  34823. /** @hidden */
  34824. updateDistanceFromListener(): void;
  34825. /**
  34826. * Sets a new custom attenuation function for the sound.
  34827. * @param callback Defines the function used for the attenuation
  34828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34829. */
  34830. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34831. /**
  34832. * Play the sound
  34833. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34834. * @param offset (optional) Start the sound at a specific time in seconds
  34835. * @param length (optional) Sound duration (in seconds)
  34836. */
  34837. play(time?: number, offset?: number, length?: number): void;
  34838. private _onended;
  34839. /**
  34840. * Stop the sound
  34841. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34842. */
  34843. stop(time?: number): void;
  34844. /**
  34845. * Put the sound in pause
  34846. */
  34847. pause(): void;
  34848. /**
  34849. * Sets a dedicated volume for this sounds
  34850. * @param newVolume Define the new volume of the sound
  34851. * @param time Define time for gradual change to new volume
  34852. */
  34853. setVolume(newVolume: number, time?: number): void;
  34854. /**
  34855. * Set the sound play back rate
  34856. * @param newPlaybackRate Define the playback rate the sound should be played at
  34857. */
  34858. setPlaybackRate(newPlaybackRate: number): void;
  34859. /**
  34860. * Gets the volume of the sound.
  34861. * @returns the volume of the sound
  34862. */
  34863. getVolume(): number;
  34864. /**
  34865. * Attach the sound to a dedicated mesh
  34866. * @param transformNode The transform node to connect the sound with
  34867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34868. */
  34869. attachToMesh(transformNode: TransformNode): void;
  34870. /**
  34871. * Detach the sound from the previously attached mesh
  34872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34873. */
  34874. detachFromMesh(): void;
  34875. private _onRegisterAfterWorldMatrixUpdate;
  34876. /**
  34877. * Clone the current sound in the scene.
  34878. * @returns the new sound clone
  34879. */
  34880. clone(): Nullable<Sound>;
  34881. /**
  34882. * Gets the current underlying audio buffer containing the data
  34883. * @returns the audio buffer
  34884. */
  34885. getAudioBuffer(): Nullable<AudioBuffer>;
  34886. /**
  34887. * Serializes the Sound in a JSON representation
  34888. * @returns the JSON representation of the sound
  34889. */
  34890. serialize(): any;
  34891. /**
  34892. * Parse a JSON representation of a sound to innstantiate in a given scene
  34893. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34894. * @param scene Define the scene the new parsed sound should be created in
  34895. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34896. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34897. * @returns the newly parsed sound
  34898. */
  34899. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34900. }
  34901. }
  34902. declare module BABYLON {
  34903. /**
  34904. * This defines an action helpful to play a defined sound on a triggered action.
  34905. */
  34906. export class PlaySoundAction extends Action {
  34907. private _sound;
  34908. /**
  34909. * Instantiate the action
  34910. * @param triggerOptions defines the trigger options
  34911. * @param sound defines the sound to play
  34912. * @param condition defines the trigger related conditions
  34913. */
  34914. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34915. /** @hidden */
  34916. _prepare(): void;
  34917. /**
  34918. * Execute the action and play the sound.
  34919. */
  34920. execute(): void;
  34921. /**
  34922. * Serializes the actions and its related information.
  34923. * @param parent defines the object to serialize in
  34924. * @returns the serialized object
  34925. */
  34926. serialize(parent: any): any;
  34927. }
  34928. /**
  34929. * This defines an action helpful to stop a defined sound on a triggered action.
  34930. */
  34931. export class StopSoundAction extends Action {
  34932. private _sound;
  34933. /**
  34934. * Instantiate the action
  34935. * @param triggerOptions defines the trigger options
  34936. * @param sound defines the sound to stop
  34937. * @param condition defines the trigger related conditions
  34938. */
  34939. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34940. /** @hidden */
  34941. _prepare(): void;
  34942. /**
  34943. * Execute the action and stop the sound.
  34944. */
  34945. execute(): void;
  34946. /**
  34947. * Serializes the actions and its related information.
  34948. * @param parent defines the object to serialize in
  34949. * @returns the serialized object
  34950. */
  34951. serialize(parent: any): any;
  34952. }
  34953. }
  34954. declare module BABYLON {
  34955. /**
  34956. * This defines an action responsible to change the value of a property
  34957. * by interpolating between its current value and the newly set one once triggered.
  34958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34959. */
  34960. export class InterpolateValueAction extends Action {
  34961. /**
  34962. * Defines the path of the property where the value should be interpolated
  34963. */
  34964. propertyPath: string;
  34965. /**
  34966. * Defines the target value at the end of the interpolation.
  34967. */
  34968. value: any;
  34969. /**
  34970. * Defines the time it will take for the property to interpolate to the value.
  34971. */
  34972. duration: number;
  34973. /**
  34974. * Defines if the other scene animations should be stopped when the action has been triggered
  34975. */
  34976. stopOtherAnimations?: boolean;
  34977. /**
  34978. * Defines a callback raised once the interpolation animation has been done.
  34979. */
  34980. onInterpolationDone?: () => void;
  34981. /**
  34982. * Observable triggered once the interpolation animation has been done.
  34983. */
  34984. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34985. private _target;
  34986. private _effectiveTarget;
  34987. private _property;
  34988. /**
  34989. * Instantiate the action
  34990. * @param triggerOptions defines the trigger options
  34991. * @param target defines the object containing the value to interpolate
  34992. * @param propertyPath defines the path to the property in the target object
  34993. * @param value defines the target value at the end of the interpolation
  34994. * @param duration deines the time it will take for the property to interpolate to the value.
  34995. * @param condition defines the trigger related conditions
  34996. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34997. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34998. */
  34999. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35000. /** @hidden */
  35001. _prepare(): void;
  35002. /**
  35003. * Execute the action starts the value interpolation.
  35004. */
  35005. execute(): void;
  35006. /**
  35007. * Serializes the actions and its related information.
  35008. * @param parent defines the object to serialize in
  35009. * @returns the serialized object
  35010. */
  35011. serialize(parent: any): any;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. /**
  35016. * Options allowed during the creation of a sound track.
  35017. */
  35018. export interface ISoundTrackOptions {
  35019. /**
  35020. * The volume the sound track should take during creation
  35021. */
  35022. volume?: number;
  35023. /**
  35024. * Define if the sound track is the main sound track of the scene
  35025. */
  35026. mainTrack?: boolean;
  35027. }
  35028. /**
  35029. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35030. * It will be also used in a future release to apply effects on a specific track.
  35031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35032. */
  35033. export class SoundTrack {
  35034. /**
  35035. * The unique identifier of the sound track in the scene.
  35036. */
  35037. id: number;
  35038. /**
  35039. * The list of sounds included in the sound track.
  35040. */
  35041. soundCollection: Array<Sound>;
  35042. private _outputAudioNode;
  35043. private _scene;
  35044. private _isMainTrack;
  35045. private _connectedAnalyser;
  35046. private _options;
  35047. private _isInitialized;
  35048. /**
  35049. * Creates a new sound track.
  35050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35051. * @param scene Define the scene the sound track belongs to
  35052. * @param options
  35053. */
  35054. constructor(scene: Scene, options?: ISoundTrackOptions);
  35055. private _initializeSoundTrackAudioGraph;
  35056. /**
  35057. * Release the sound track and its associated resources
  35058. */
  35059. dispose(): void;
  35060. /**
  35061. * Adds a sound to this sound track
  35062. * @param sound define the cound to add
  35063. * @ignoreNaming
  35064. */
  35065. AddSound(sound: Sound): void;
  35066. /**
  35067. * Removes a sound to this sound track
  35068. * @param sound define the cound to remove
  35069. * @ignoreNaming
  35070. */
  35071. RemoveSound(sound: Sound): void;
  35072. /**
  35073. * Set a global volume for the full sound track.
  35074. * @param newVolume Define the new volume of the sound track
  35075. */
  35076. setVolume(newVolume: number): void;
  35077. /**
  35078. * Switch the panning model to HRTF:
  35079. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35081. */
  35082. switchPanningModelToHRTF(): void;
  35083. /**
  35084. * Switch the panning model to Equal Power:
  35085. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35087. */
  35088. switchPanningModelToEqualPower(): void;
  35089. /**
  35090. * Connect the sound track to an audio analyser allowing some amazing
  35091. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35093. * @param analyser The analyser to connect to the engine
  35094. */
  35095. connectToAnalyser(analyser: Analyser): void;
  35096. }
  35097. }
  35098. declare module BABYLON {
  35099. interface AbstractScene {
  35100. /**
  35101. * The list of sounds used in the scene.
  35102. */
  35103. sounds: Nullable<Array<Sound>>;
  35104. }
  35105. interface Scene {
  35106. /**
  35107. * @hidden
  35108. * Backing field
  35109. */
  35110. _mainSoundTrack: SoundTrack;
  35111. /**
  35112. * The main sound track played by the scene.
  35113. * It cotains your primary collection of sounds.
  35114. */
  35115. mainSoundTrack: SoundTrack;
  35116. /**
  35117. * The list of sound tracks added to the scene
  35118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35119. */
  35120. soundTracks: Nullable<Array<SoundTrack>>;
  35121. /**
  35122. * Gets a sound using a given name
  35123. * @param name defines the name to search for
  35124. * @return the found sound or null if not found at all.
  35125. */
  35126. getSoundByName(name: string): Nullable<Sound>;
  35127. /**
  35128. * Gets or sets if audio support is enabled
  35129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35130. */
  35131. audioEnabled: boolean;
  35132. /**
  35133. * Gets or sets if audio will be output to headphones
  35134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35135. */
  35136. headphone: boolean;
  35137. }
  35138. /**
  35139. * Defines the sound scene component responsible to manage any sounds
  35140. * in a given scene.
  35141. */
  35142. export class AudioSceneComponent implements ISceneSerializableComponent {
  35143. /**
  35144. * The component name helpfull to identify the component in the list of scene components.
  35145. */
  35146. readonly name: string;
  35147. /**
  35148. * The scene the component belongs to.
  35149. */
  35150. scene: Scene;
  35151. private _audioEnabled;
  35152. /**
  35153. * Gets whether audio is enabled or not.
  35154. * Please use related enable/disable method to switch state.
  35155. */
  35156. readonly audioEnabled: boolean;
  35157. private _headphone;
  35158. /**
  35159. * Gets whether audio is outputing to headphone or not.
  35160. * Please use the according Switch methods to change output.
  35161. */
  35162. readonly headphone: boolean;
  35163. /**
  35164. * Creates a new instance of the component for the given scene
  35165. * @param scene Defines the scene to register the component in
  35166. */
  35167. constructor(scene: Scene);
  35168. /**
  35169. * Registers the component in a given scene
  35170. */
  35171. register(): void;
  35172. /**
  35173. * Rebuilds the elements related to this component in case of
  35174. * context lost for instance.
  35175. */
  35176. rebuild(): void;
  35177. /**
  35178. * Serializes the component data to the specified json object
  35179. * @param serializationObject The object to serialize to
  35180. */
  35181. serialize(serializationObject: any): void;
  35182. /**
  35183. * Adds all the elements from the container to the scene
  35184. * @param container the container holding the elements
  35185. */
  35186. addFromContainer(container: AbstractScene): void;
  35187. /**
  35188. * Removes all the elements in the container from the scene
  35189. * @param container contains the elements to remove
  35190. * @param dispose if the removed element should be disposed (default: false)
  35191. */
  35192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35193. /**
  35194. * Disposes the component and the associated ressources.
  35195. */
  35196. dispose(): void;
  35197. /**
  35198. * Disables audio in the associated scene.
  35199. */
  35200. disableAudio(): void;
  35201. /**
  35202. * Enables audio in the associated scene.
  35203. */
  35204. enableAudio(): void;
  35205. /**
  35206. * Switch audio to headphone output.
  35207. */
  35208. switchAudioModeForHeadphones(): void;
  35209. /**
  35210. * Switch audio to normal speakers.
  35211. */
  35212. switchAudioModeForNormalSpeakers(): void;
  35213. private _afterRender;
  35214. }
  35215. }
  35216. declare module BABYLON {
  35217. /**
  35218. * Wraps one or more Sound objects and selects one with random weight for playback.
  35219. */
  35220. export class WeightedSound {
  35221. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35222. loop: boolean;
  35223. private _coneInnerAngle;
  35224. private _coneOuterAngle;
  35225. private _volume;
  35226. /** A Sound is currently playing. */
  35227. isPlaying: boolean;
  35228. /** A Sound is currently paused. */
  35229. isPaused: boolean;
  35230. private _sounds;
  35231. private _weights;
  35232. private _currentIndex?;
  35233. /**
  35234. * Creates a new WeightedSound from the list of sounds given.
  35235. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35236. * @param sounds Array of Sounds that will be selected from.
  35237. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35238. */
  35239. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35240. /**
  35241. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35242. */
  35243. /**
  35244. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35245. */
  35246. directionalConeInnerAngle: number;
  35247. /**
  35248. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35249. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35250. */
  35251. /**
  35252. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35253. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35254. */
  35255. directionalConeOuterAngle: number;
  35256. /**
  35257. * Playback volume.
  35258. */
  35259. /**
  35260. * Playback volume.
  35261. */
  35262. volume: number;
  35263. private _onended;
  35264. /**
  35265. * Suspend playback
  35266. */
  35267. pause(): void;
  35268. /**
  35269. * Stop playback
  35270. */
  35271. stop(): void;
  35272. /**
  35273. * Start playback.
  35274. * @param startOffset Position the clip head at a specific time in seconds.
  35275. */
  35276. play(startOffset?: number): void;
  35277. }
  35278. }
  35279. declare module BABYLON {
  35280. /**
  35281. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35283. */
  35284. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35285. /**
  35286. * Gets the name of the behavior.
  35287. */
  35288. readonly name: string;
  35289. /**
  35290. * The easing function used by animations
  35291. */
  35292. static EasingFunction: BackEase;
  35293. /**
  35294. * The easing mode used by animations
  35295. */
  35296. static EasingMode: number;
  35297. /**
  35298. * The duration of the animation, in milliseconds
  35299. */
  35300. transitionDuration: number;
  35301. /**
  35302. * Length of the distance animated by the transition when lower radius is reached
  35303. */
  35304. lowerRadiusTransitionRange: number;
  35305. /**
  35306. * Length of the distance animated by the transition when upper radius is reached
  35307. */
  35308. upperRadiusTransitionRange: number;
  35309. private _autoTransitionRange;
  35310. /**
  35311. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35312. */
  35313. /**
  35314. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35315. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35316. */
  35317. autoTransitionRange: boolean;
  35318. private _attachedCamera;
  35319. private _onAfterCheckInputsObserver;
  35320. private _onMeshTargetChangedObserver;
  35321. /**
  35322. * Initializes the behavior.
  35323. */
  35324. init(): void;
  35325. /**
  35326. * Attaches the behavior to its arc rotate camera.
  35327. * @param camera Defines the camera to attach the behavior to
  35328. */
  35329. attach(camera: ArcRotateCamera): void;
  35330. /**
  35331. * Detaches the behavior from its current arc rotate camera.
  35332. */
  35333. detach(): void;
  35334. private _radiusIsAnimating;
  35335. private _radiusBounceTransition;
  35336. private _animatables;
  35337. private _cachedWheelPrecision;
  35338. /**
  35339. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35340. * @param radiusLimit The limit to check against.
  35341. * @return Bool to indicate if at limit.
  35342. */
  35343. private _isRadiusAtLimit;
  35344. /**
  35345. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35346. * @param radiusDelta The delta by which to animate to. Can be negative.
  35347. */
  35348. private _applyBoundRadiusAnimation;
  35349. /**
  35350. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35351. */
  35352. protected _clearAnimationLocks(): void;
  35353. /**
  35354. * Stops and removes all animations that have been applied to the camera
  35355. */
  35356. stopAllAnimations(): void;
  35357. }
  35358. }
  35359. declare module BABYLON {
  35360. /**
  35361. * 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.
  35362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35363. */
  35364. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35365. /**
  35366. * Gets the name of the behavior.
  35367. */
  35368. readonly name: string;
  35369. private _mode;
  35370. private _radiusScale;
  35371. private _positionScale;
  35372. private _defaultElevation;
  35373. private _elevationReturnTime;
  35374. private _elevationReturnWaitTime;
  35375. private _zoomStopsAnimation;
  35376. private _framingTime;
  35377. /**
  35378. * The easing function used by animations
  35379. */
  35380. static EasingFunction: ExponentialEase;
  35381. /**
  35382. * The easing mode used by animations
  35383. */
  35384. static EasingMode: number;
  35385. /**
  35386. * Sets the current mode used by the behavior
  35387. */
  35388. /**
  35389. * Gets current mode used by the behavior.
  35390. */
  35391. mode: number;
  35392. /**
  35393. * Sets the scale applied to the radius (1 by default)
  35394. */
  35395. /**
  35396. * Gets the scale applied to the radius
  35397. */
  35398. radiusScale: number;
  35399. /**
  35400. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35401. */
  35402. /**
  35403. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35404. */
  35405. positionScale: number;
  35406. /**
  35407. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35408. * behaviour is triggered, in radians.
  35409. */
  35410. /**
  35411. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35412. * behaviour is triggered, in radians.
  35413. */
  35414. defaultElevation: number;
  35415. /**
  35416. * Sets the time (in milliseconds) taken to return to the default beta position.
  35417. * Negative value indicates camera should not return to default.
  35418. */
  35419. /**
  35420. * Gets the time (in milliseconds) taken to return to the default beta position.
  35421. * Negative value indicates camera should not return to default.
  35422. */
  35423. elevationReturnTime: number;
  35424. /**
  35425. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35426. */
  35427. /**
  35428. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35429. */
  35430. elevationReturnWaitTime: number;
  35431. /**
  35432. * Sets the flag that indicates if user zooming should stop animation.
  35433. */
  35434. /**
  35435. * Gets the flag that indicates if user zooming should stop animation.
  35436. */
  35437. zoomStopsAnimation: boolean;
  35438. /**
  35439. * Sets the transition time when framing the mesh, in milliseconds
  35440. */
  35441. /**
  35442. * Gets the transition time when framing the mesh, in milliseconds
  35443. */
  35444. framingTime: number;
  35445. /**
  35446. * Define if the behavior should automatically change the configured
  35447. * camera limits and sensibilities.
  35448. */
  35449. autoCorrectCameraLimitsAndSensibility: boolean;
  35450. private _onPrePointerObservableObserver;
  35451. private _onAfterCheckInputsObserver;
  35452. private _onMeshTargetChangedObserver;
  35453. private _attachedCamera;
  35454. private _isPointerDown;
  35455. private _lastInteractionTime;
  35456. /**
  35457. * Initializes the behavior.
  35458. */
  35459. init(): void;
  35460. /**
  35461. * Attaches the behavior to its arc rotate camera.
  35462. * @param camera Defines the camera to attach the behavior to
  35463. */
  35464. attach(camera: ArcRotateCamera): void;
  35465. /**
  35466. * Detaches the behavior from its current arc rotate camera.
  35467. */
  35468. detach(): void;
  35469. private _animatables;
  35470. private _betaIsAnimating;
  35471. private _betaTransition;
  35472. private _radiusTransition;
  35473. private _vectorTransition;
  35474. /**
  35475. * Targets the given mesh and updates zoom level accordingly.
  35476. * @param mesh The mesh to target.
  35477. * @param radius Optional. If a cached radius position already exists, overrides default.
  35478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35481. */
  35482. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35483. /**
  35484. * Targets the given mesh with its children and updates zoom level accordingly.
  35485. * @param mesh The mesh to target.
  35486. * @param radius Optional. If a cached radius position already exists, overrides default.
  35487. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35490. */
  35491. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35492. /**
  35493. * Targets the given meshes with their children and updates zoom level accordingly.
  35494. * @param meshes The mesh to target.
  35495. * @param radius Optional. If a cached radius position already exists, overrides default.
  35496. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35499. */
  35500. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35501. /**
  35502. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35503. * @param minimumWorld Determines the smaller position of the bounding box extend
  35504. * @param maximumWorld Determines the bigger position of the bounding box extend
  35505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35507. */
  35508. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35509. /**
  35510. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35511. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35512. * frustum width.
  35513. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35514. * to fully enclose the mesh in the viewing frustum.
  35515. */
  35516. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35517. /**
  35518. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35519. * is automatically returned to its default position (expected to be above ground plane).
  35520. */
  35521. private _maintainCameraAboveGround;
  35522. /**
  35523. * Returns the frustum slope based on the canvas ratio and camera FOV
  35524. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35525. */
  35526. private _getFrustumSlope;
  35527. /**
  35528. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35529. */
  35530. private _clearAnimationLocks;
  35531. /**
  35532. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35533. */
  35534. private _applyUserInteraction;
  35535. /**
  35536. * Stops and removes all animations that have been applied to the camera
  35537. */
  35538. stopAllAnimations(): void;
  35539. /**
  35540. * Gets a value indicating if the user is moving the camera
  35541. */
  35542. readonly isUserIsMoving: boolean;
  35543. /**
  35544. * The camera can move all the way towards the mesh.
  35545. */
  35546. static IgnoreBoundsSizeMode: number;
  35547. /**
  35548. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35549. */
  35550. static FitFrustumSidesMode: number;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. /**
  35555. * Base class for Camera Pointer Inputs.
  35556. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35557. * for example usage.
  35558. */
  35559. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35560. /**
  35561. * Defines the camera the input is attached to.
  35562. */
  35563. abstract camera: Camera;
  35564. /**
  35565. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35566. */
  35567. protected _altKey: boolean;
  35568. protected _ctrlKey: boolean;
  35569. protected _metaKey: boolean;
  35570. protected _shiftKey: boolean;
  35571. /**
  35572. * Which mouse buttons were pressed at time of last mouse event.
  35573. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35574. */
  35575. protected _buttonsPressed: number;
  35576. /**
  35577. * Defines the buttons associated with the input to handle camera move.
  35578. */
  35579. buttons: number[];
  35580. /**
  35581. * Attach the input controls to a specific dom element to get the input from.
  35582. * @param element Defines the element the controls should be listened from
  35583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35584. */
  35585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35586. /**
  35587. * Detach the current controls from the specified dom element.
  35588. * @param element Defines the element to stop listening the inputs from
  35589. */
  35590. detachControl(element: Nullable<HTMLElement>): void;
  35591. /**
  35592. * Gets the class name of the current input.
  35593. * @returns the class name
  35594. */
  35595. getClassName(): string;
  35596. /**
  35597. * Get the friendly name associated with the input class.
  35598. * @returns the input friendly name
  35599. */
  35600. getSimpleName(): string;
  35601. /**
  35602. * Called on pointer POINTERDOUBLETAP event.
  35603. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35604. */
  35605. protected onDoubleTap(type: string): void;
  35606. /**
  35607. * Called on pointer POINTERMOVE event if only a single touch is active.
  35608. * Override this method to provide functionality.
  35609. */
  35610. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35611. /**
  35612. * Called on pointer POINTERMOVE event if multiple touches are active.
  35613. * Override this method to provide functionality.
  35614. */
  35615. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35616. /**
  35617. * Called on JS contextmenu event.
  35618. * Override this method to provide functionality.
  35619. */
  35620. protected onContextMenu(evt: PointerEvent): void;
  35621. /**
  35622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35623. * press.
  35624. * Override this method to provide functionality.
  35625. */
  35626. protected onButtonDown(evt: PointerEvent): void;
  35627. /**
  35628. * Called each time a new POINTERUP event occurs. Ie, for each button
  35629. * release.
  35630. * Override this method to provide functionality.
  35631. */
  35632. protected onButtonUp(evt: PointerEvent): void;
  35633. /**
  35634. * Called when window becomes inactive.
  35635. * Override this method to provide functionality.
  35636. */
  35637. protected onLostFocus(): void;
  35638. private _pointerInput;
  35639. private _observer;
  35640. private _onLostFocus;
  35641. private pointA;
  35642. private pointB;
  35643. }
  35644. }
  35645. declare module BABYLON {
  35646. /**
  35647. * Manage the pointers inputs to control an arc rotate camera.
  35648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35649. */
  35650. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35651. /**
  35652. * Defines the camera the input is attached to.
  35653. */
  35654. camera: ArcRotateCamera;
  35655. /**
  35656. * Gets the class name of the current input.
  35657. * @returns the class name
  35658. */
  35659. getClassName(): string;
  35660. /**
  35661. * Defines the buttons associated with the input to handle camera move.
  35662. */
  35663. buttons: number[];
  35664. /**
  35665. * Defines the pointer angular sensibility along the X axis or how fast is
  35666. * the camera rotating.
  35667. */
  35668. angularSensibilityX: number;
  35669. /**
  35670. * Defines the pointer angular sensibility along the Y axis or how fast is
  35671. * the camera rotating.
  35672. */
  35673. angularSensibilityY: number;
  35674. /**
  35675. * Defines the pointer pinch precision or how fast is the camera zooming.
  35676. */
  35677. pinchPrecision: number;
  35678. /**
  35679. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35680. * from 0.
  35681. * It defines the percentage of current camera.radius to use as delta when
  35682. * pinch zoom is used.
  35683. */
  35684. pinchDeltaPercentage: number;
  35685. /**
  35686. * Defines the pointer panning sensibility or how fast is the camera moving.
  35687. */
  35688. panningSensibility: number;
  35689. /**
  35690. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35691. */
  35692. multiTouchPanning: boolean;
  35693. /**
  35694. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35695. * zoom (pinch) through multitouch.
  35696. */
  35697. multiTouchPanAndZoom: boolean;
  35698. /**
  35699. * Revers pinch action direction.
  35700. */
  35701. pinchInwards: boolean;
  35702. private _isPanClick;
  35703. private _twoFingerActivityCount;
  35704. private _isPinching;
  35705. /**
  35706. * Called on pointer POINTERMOVE event if only a single touch is active.
  35707. */
  35708. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35709. /**
  35710. * Called on pointer POINTERDOUBLETAP event.
  35711. */
  35712. protected onDoubleTap(type: string): void;
  35713. /**
  35714. * Called on pointer POINTERMOVE event if multiple touches are active.
  35715. */
  35716. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35717. /**
  35718. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35719. * press.
  35720. */
  35721. protected onButtonDown(evt: PointerEvent): void;
  35722. /**
  35723. * Called each time a new POINTERUP event occurs. Ie, for each button
  35724. * release.
  35725. */
  35726. protected onButtonUp(evt: PointerEvent): void;
  35727. /**
  35728. * Called when window becomes inactive.
  35729. */
  35730. protected onLostFocus(): void;
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35737. */
  35738. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35739. /**
  35740. * Defines the camera the input is attached to.
  35741. */
  35742. camera: ArcRotateCamera;
  35743. /**
  35744. * Defines the list of key codes associated with the up action (increase alpha)
  35745. */
  35746. keysUp: number[];
  35747. /**
  35748. * Defines the list of key codes associated with the down action (decrease alpha)
  35749. */
  35750. keysDown: number[];
  35751. /**
  35752. * Defines the list of key codes associated with the left action (increase beta)
  35753. */
  35754. keysLeft: number[];
  35755. /**
  35756. * Defines the list of key codes associated with the right action (decrease beta)
  35757. */
  35758. keysRight: number[];
  35759. /**
  35760. * Defines the list of key codes associated with the reset action.
  35761. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35762. */
  35763. keysReset: number[];
  35764. /**
  35765. * Defines the panning sensibility of the inputs.
  35766. * (How fast is the camera paning)
  35767. */
  35768. panningSensibility: number;
  35769. /**
  35770. * Defines the zooming sensibility of the inputs.
  35771. * (How fast is the camera zooming)
  35772. */
  35773. zoomingSensibility: number;
  35774. /**
  35775. * Defines wether maintaining the alt key down switch the movement mode from
  35776. * orientation to zoom.
  35777. */
  35778. useAltToZoom: boolean;
  35779. /**
  35780. * Rotation speed of the camera
  35781. */
  35782. angularSpeed: number;
  35783. private _keys;
  35784. private _ctrlPressed;
  35785. private _altPressed;
  35786. private _onCanvasBlurObserver;
  35787. private _onKeyboardObserver;
  35788. private _engine;
  35789. private _scene;
  35790. /**
  35791. * Attach the input controls to a specific dom element to get the input from.
  35792. * @param element Defines the element the controls should be listened from
  35793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35794. */
  35795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35796. /**
  35797. * Detach the current controls from the specified dom element.
  35798. * @param element Defines the element to stop listening the inputs from
  35799. */
  35800. detachControl(element: Nullable<HTMLElement>): void;
  35801. /**
  35802. * Update the current camera state depending on the inputs that have been used this frame.
  35803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35804. */
  35805. checkInputs(): void;
  35806. /**
  35807. * Gets the class name of the current intput.
  35808. * @returns the class name
  35809. */
  35810. getClassName(): string;
  35811. /**
  35812. * Get the friendly name associated with the input class.
  35813. * @returns the input friendly name
  35814. */
  35815. getSimpleName(): string;
  35816. }
  35817. }
  35818. declare module BABYLON {
  35819. /**
  35820. * Manage the mouse wheel inputs to control an arc rotate camera.
  35821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35822. */
  35823. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35824. /**
  35825. * Defines the camera the input is attached to.
  35826. */
  35827. camera: ArcRotateCamera;
  35828. /**
  35829. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35830. */
  35831. wheelPrecision: number;
  35832. /**
  35833. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35834. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35835. */
  35836. wheelDeltaPercentage: number;
  35837. private _wheel;
  35838. private _observer;
  35839. private computeDeltaFromMouseWheelLegacyEvent;
  35840. /**
  35841. * Attach the input controls to a specific dom element to get the input from.
  35842. * @param element Defines the element the controls should be listened from
  35843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35844. */
  35845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35846. /**
  35847. * Detach the current controls from the specified dom element.
  35848. * @param element Defines the element to stop listening the inputs from
  35849. */
  35850. detachControl(element: Nullable<HTMLElement>): void;
  35851. /**
  35852. * Gets the class name of the current intput.
  35853. * @returns the class name
  35854. */
  35855. getClassName(): string;
  35856. /**
  35857. * Get the friendly name associated with the input class.
  35858. * @returns the input friendly name
  35859. */
  35860. getSimpleName(): string;
  35861. }
  35862. }
  35863. declare module BABYLON {
  35864. /**
  35865. * Default Inputs manager for the ArcRotateCamera.
  35866. * It groups all the default supported inputs for ease of use.
  35867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35868. */
  35869. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35870. /**
  35871. * Instantiates a new ArcRotateCameraInputsManager.
  35872. * @param camera Defines the camera the inputs belong to
  35873. */
  35874. constructor(camera: ArcRotateCamera);
  35875. /**
  35876. * Add mouse wheel input support to the input manager.
  35877. * @returns the current input manager
  35878. */
  35879. addMouseWheel(): ArcRotateCameraInputsManager;
  35880. /**
  35881. * Add pointers input support to the input manager.
  35882. * @returns the current input manager
  35883. */
  35884. addPointers(): ArcRotateCameraInputsManager;
  35885. /**
  35886. * Add keyboard input support to the input manager.
  35887. * @returns the current input manager
  35888. */
  35889. addKeyboard(): ArcRotateCameraInputsManager;
  35890. }
  35891. }
  35892. declare module BABYLON {
  35893. /**
  35894. * This represents an orbital type of camera.
  35895. *
  35896. * 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.
  35897. * 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.
  35898. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35899. */
  35900. export class ArcRotateCamera extends TargetCamera {
  35901. /**
  35902. * Defines the rotation angle of the camera along the longitudinal axis.
  35903. */
  35904. alpha: number;
  35905. /**
  35906. * Defines the rotation angle of the camera along the latitudinal axis.
  35907. */
  35908. beta: number;
  35909. /**
  35910. * Defines the radius of the camera from it s target point.
  35911. */
  35912. radius: number;
  35913. protected _target: Vector3;
  35914. protected _targetHost: Nullable<AbstractMesh>;
  35915. /**
  35916. * Defines the target point of the camera.
  35917. * The camera looks towards it form the radius distance.
  35918. */
  35919. target: Vector3;
  35920. /**
  35921. * Define the current local position of the camera in the scene
  35922. */
  35923. position: Vector3;
  35924. protected _upVector: Vector3;
  35925. protected _upToYMatrix: Matrix;
  35926. protected _YToUpMatrix: Matrix;
  35927. /**
  35928. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35929. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35930. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35931. */
  35932. upVector: Vector3;
  35933. /**
  35934. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35935. */
  35936. setMatUp(): void;
  35937. /**
  35938. * Current inertia value on the longitudinal axis.
  35939. * The bigger this number the longer it will take for the camera to stop.
  35940. */
  35941. inertialAlphaOffset: number;
  35942. /**
  35943. * Current inertia value on the latitudinal axis.
  35944. * The bigger this number the longer it will take for the camera to stop.
  35945. */
  35946. inertialBetaOffset: number;
  35947. /**
  35948. * Current inertia value on the radius axis.
  35949. * The bigger this number the longer it will take for the camera to stop.
  35950. */
  35951. inertialRadiusOffset: number;
  35952. /**
  35953. * Minimum allowed angle on the longitudinal axis.
  35954. * This can help limiting how the Camera is able to move in the scene.
  35955. */
  35956. lowerAlphaLimit: Nullable<number>;
  35957. /**
  35958. * Maximum allowed angle on the longitudinal axis.
  35959. * This can help limiting how the Camera is able to move in the scene.
  35960. */
  35961. upperAlphaLimit: Nullable<number>;
  35962. /**
  35963. * Minimum allowed angle on the latitudinal axis.
  35964. * This can help limiting how the Camera is able to move in the scene.
  35965. */
  35966. lowerBetaLimit: number;
  35967. /**
  35968. * Maximum allowed angle on the latitudinal axis.
  35969. * This can help limiting how the Camera is able to move in the scene.
  35970. */
  35971. upperBetaLimit: number;
  35972. /**
  35973. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35974. * This can help limiting how the Camera is able to move in the scene.
  35975. */
  35976. lowerRadiusLimit: Nullable<number>;
  35977. /**
  35978. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35979. * This can help limiting how the Camera is able to move in the scene.
  35980. */
  35981. upperRadiusLimit: Nullable<number>;
  35982. /**
  35983. * Defines the current inertia value used during panning of the camera along the X axis.
  35984. */
  35985. inertialPanningX: number;
  35986. /**
  35987. * Defines the current inertia value used during panning of the camera along the Y axis.
  35988. */
  35989. inertialPanningY: number;
  35990. /**
  35991. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35992. * Basically if your fingers moves away from more than this distance you will be considered
  35993. * in pinch mode.
  35994. */
  35995. pinchToPanMaxDistance: number;
  35996. /**
  35997. * Defines the maximum distance the camera can pan.
  35998. * This could help keeping the cammera always in your scene.
  35999. */
  36000. panningDistanceLimit: Nullable<number>;
  36001. /**
  36002. * Defines the target of the camera before paning.
  36003. */
  36004. panningOriginTarget: Vector3;
  36005. /**
  36006. * Defines the value of the inertia used during panning.
  36007. * 0 would mean stop inertia and one would mean no decelleration at all.
  36008. */
  36009. panningInertia: number;
  36010. /**
  36011. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36012. */
  36013. angularSensibilityX: number;
  36014. /**
  36015. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36016. */
  36017. angularSensibilityY: number;
  36018. /**
  36019. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36020. */
  36021. pinchPrecision: number;
  36022. /**
  36023. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36024. * It will be used instead of pinchDeltaPrecision if different from 0.
  36025. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36026. */
  36027. pinchDeltaPercentage: number;
  36028. /**
  36029. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36030. */
  36031. panningSensibility: number;
  36032. /**
  36033. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36034. */
  36035. keysUp: number[];
  36036. /**
  36037. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36038. */
  36039. keysDown: number[];
  36040. /**
  36041. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36042. */
  36043. keysLeft: number[];
  36044. /**
  36045. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36046. */
  36047. keysRight: number[];
  36048. /**
  36049. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36050. */
  36051. wheelPrecision: number;
  36052. /**
  36053. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36054. * It will be used instead of pinchDeltaPrecision if different from 0.
  36055. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36056. */
  36057. wheelDeltaPercentage: number;
  36058. /**
  36059. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36060. */
  36061. zoomOnFactor: number;
  36062. /**
  36063. * Defines a screen offset for the camera position.
  36064. */
  36065. targetScreenOffset: Vector2;
  36066. /**
  36067. * Allows the camera to be completely reversed.
  36068. * If false the camera can not arrive upside down.
  36069. */
  36070. allowUpsideDown: boolean;
  36071. /**
  36072. * Define if double tap/click is used to restore the previously saved state of the camera.
  36073. */
  36074. useInputToRestoreState: boolean;
  36075. /** @hidden */
  36076. _viewMatrix: Matrix;
  36077. /** @hidden */
  36078. _useCtrlForPanning: boolean;
  36079. /** @hidden */
  36080. _panningMouseButton: number;
  36081. /**
  36082. * Defines the input associated to the camera.
  36083. */
  36084. inputs: ArcRotateCameraInputsManager;
  36085. /** @hidden */
  36086. _reset: () => void;
  36087. /**
  36088. * Defines the allowed panning axis.
  36089. */
  36090. panningAxis: Vector3;
  36091. protected _localDirection: Vector3;
  36092. protected _transformedDirection: Vector3;
  36093. private _bouncingBehavior;
  36094. /**
  36095. * Gets the bouncing behavior of the camera if it has been enabled.
  36096. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36097. */
  36098. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36099. /**
  36100. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36102. */
  36103. useBouncingBehavior: boolean;
  36104. private _framingBehavior;
  36105. /**
  36106. * Gets the framing behavior of the camera if it has been enabled.
  36107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36108. */
  36109. readonly framingBehavior: Nullable<FramingBehavior>;
  36110. /**
  36111. * Defines if the framing behavior of the camera is enabled on the camera.
  36112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36113. */
  36114. useFramingBehavior: boolean;
  36115. private _autoRotationBehavior;
  36116. /**
  36117. * Gets the auto rotation behavior of the camera if it has been enabled.
  36118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36119. */
  36120. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36121. /**
  36122. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36124. */
  36125. useAutoRotationBehavior: boolean;
  36126. /**
  36127. * Observable triggered when the mesh target has been changed on the camera.
  36128. */
  36129. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36130. /**
  36131. * Event raised when the camera is colliding with a mesh.
  36132. */
  36133. onCollide: (collidedMesh: AbstractMesh) => void;
  36134. /**
  36135. * Defines whether the camera should check collision with the objects oh the scene.
  36136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36137. */
  36138. checkCollisions: boolean;
  36139. /**
  36140. * Defines the collision radius of the camera.
  36141. * This simulates a sphere around the camera.
  36142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36143. */
  36144. collisionRadius: Vector3;
  36145. protected _collider: Collider;
  36146. protected _previousPosition: Vector3;
  36147. protected _collisionVelocity: Vector3;
  36148. protected _newPosition: Vector3;
  36149. protected _previousAlpha: number;
  36150. protected _previousBeta: number;
  36151. protected _previousRadius: number;
  36152. protected _collisionTriggered: boolean;
  36153. protected _targetBoundingCenter: Nullable<Vector3>;
  36154. private _computationVector;
  36155. /**
  36156. * Instantiates a new ArcRotateCamera in a given scene
  36157. * @param name Defines the name of the camera
  36158. * @param alpha Defines the camera rotation along the logitudinal axis
  36159. * @param beta Defines the camera rotation along the latitudinal axis
  36160. * @param radius Defines the camera distance from its target
  36161. * @param target Defines the camera target
  36162. * @param scene Defines the scene the camera belongs to
  36163. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36164. */
  36165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36166. /** @hidden */
  36167. _initCache(): void;
  36168. /** @hidden */
  36169. _updateCache(ignoreParentClass?: boolean): void;
  36170. protected _getTargetPosition(): Vector3;
  36171. private _storedAlpha;
  36172. private _storedBeta;
  36173. private _storedRadius;
  36174. private _storedTarget;
  36175. /**
  36176. * Stores the current state of the camera (alpha, beta, radius and target)
  36177. * @returns the camera itself
  36178. */
  36179. storeState(): Camera;
  36180. /**
  36181. * @hidden
  36182. * Restored camera state. You must call storeState() first
  36183. */
  36184. _restoreStateValues(): boolean;
  36185. /** @hidden */
  36186. _isSynchronizedViewMatrix(): boolean;
  36187. /**
  36188. * Attached controls to the current camera.
  36189. * @param element Defines the element the controls should be listened from
  36190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36191. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36192. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36193. */
  36194. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36195. /**
  36196. * Detach the current controls from the camera.
  36197. * The camera will stop reacting to inputs.
  36198. * @param element Defines the element to stop listening the inputs from
  36199. */
  36200. detachControl(element: HTMLElement): void;
  36201. /** @hidden */
  36202. _checkInputs(): void;
  36203. protected _checkLimits(): void;
  36204. /**
  36205. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36206. */
  36207. rebuildAnglesAndRadius(): void;
  36208. /**
  36209. * Use a position to define the current camera related information like aplha, beta and radius
  36210. * @param position Defines the position to set the camera at
  36211. */
  36212. setPosition(position: Vector3): void;
  36213. /**
  36214. * Defines the target the camera should look at.
  36215. * This will automatically adapt alpha beta and radius to fit within the new target.
  36216. * @param target Defines the new target as a Vector or a mesh
  36217. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36218. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36219. */
  36220. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36221. /** @hidden */
  36222. _getViewMatrix(): Matrix;
  36223. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36224. /**
  36225. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36226. * @param meshes Defines the mesh to zoom on
  36227. * @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)
  36228. */
  36229. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36230. /**
  36231. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36232. * The target will be changed but the radius
  36233. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36234. * @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)
  36235. */
  36236. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36237. min: Vector3;
  36238. max: Vector3;
  36239. distance: number;
  36240. }, doNotUpdateMaxZ?: boolean): void;
  36241. /**
  36242. * @override
  36243. * Override Camera.createRigCamera
  36244. */
  36245. createRigCamera(name: string, cameraIndex: number): Camera;
  36246. /**
  36247. * @hidden
  36248. * @override
  36249. * Override Camera._updateRigCameras
  36250. */
  36251. _updateRigCameras(): void;
  36252. /**
  36253. * Destroy the camera and release the current resources hold by it.
  36254. */
  36255. dispose(): void;
  36256. /**
  36257. * Gets the current object class name.
  36258. * @return the class name
  36259. */
  36260. getClassName(): string;
  36261. }
  36262. }
  36263. declare module BABYLON {
  36264. /**
  36265. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36267. */
  36268. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36269. /**
  36270. * Gets the name of the behavior.
  36271. */
  36272. readonly name: string;
  36273. private _zoomStopsAnimation;
  36274. private _idleRotationSpeed;
  36275. private _idleRotationWaitTime;
  36276. private _idleRotationSpinupTime;
  36277. /**
  36278. * Sets the flag that indicates if user zooming should stop animation.
  36279. */
  36280. /**
  36281. * Gets the flag that indicates if user zooming should stop animation.
  36282. */
  36283. zoomStopsAnimation: boolean;
  36284. /**
  36285. * Sets the default speed at which the camera rotates around the model.
  36286. */
  36287. /**
  36288. * Gets the default speed at which the camera rotates around the model.
  36289. */
  36290. idleRotationSpeed: number;
  36291. /**
  36292. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36293. */
  36294. /**
  36295. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36296. */
  36297. idleRotationWaitTime: number;
  36298. /**
  36299. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36300. */
  36301. /**
  36302. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36303. */
  36304. idleRotationSpinupTime: number;
  36305. /**
  36306. * Gets a value indicating if the camera is currently rotating because of this behavior
  36307. */
  36308. readonly rotationInProgress: boolean;
  36309. private _onPrePointerObservableObserver;
  36310. private _onAfterCheckInputsObserver;
  36311. private _attachedCamera;
  36312. private _isPointerDown;
  36313. private _lastFrameTime;
  36314. private _lastInteractionTime;
  36315. private _cameraRotationSpeed;
  36316. /**
  36317. * Initializes the behavior.
  36318. */
  36319. init(): void;
  36320. /**
  36321. * Attaches the behavior to its arc rotate camera.
  36322. * @param camera Defines the camera to attach the behavior to
  36323. */
  36324. attach(camera: ArcRotateCamera): void;
  36325. /**
  36326. * Detaches the behavior from its current arc rotate camera.
  36327. */
  36328. detach(): void;
  36329. /**
  36330. * Returns true if user is scrolling.
  36331. * @return true if user is scrolling.
  36332. */
  36333. private _userIsZooming;
  36334. private _lastFrameRadius;
  36335. private _shouldAnimationStopForInteraction;
  36336. /**
  36337. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36338. */
  36339. private _applyUserInteraction;
  36340. private _userIsMoving;
  36341. }
  36342. }
  36343. declare module BABYLON {
  36344. /**
  36345. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36346. */
  36347. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36348. private ui;
  36349. /**
  36350. * The name of the behavior
  36351. */
  36352. name: string;
  36353. /**
  36354. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36355. */
  36356. distanceAwayFromFace: number;
  36357. /**
  36358. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36359. */
  36360. distanceAwayFromBottomOfFace: number;
  36361. private _faceVectors;
  36362. private _target;
  36363. private _scene;
  36364. private _onRenderObserver;
  36365. private _tmpMatrix;
  36366. private _tmpVector;
  36367. /**
  36368. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36369. * @param ui The transform node that should be attched to the mesh
  36370. */
  36371. constructor(ui: TransformNode);
  36372. /**
  36373. * Initializes the behavior
  36374. */
  36375. init(): void;
  36376. private _closestFace;
  36377. private _zeroVector;
  36378. private _lookAtTmpMatrix;
  36379. private _lookAtToRef;
  36380. /**
  36381. * Attaches the AttachToBoxBehavior to the passed in mesh
  36382. * @param target The mesh that the specified node will be attached to
  36383. */
  36384. attach(target: Mesh): void;
  36385. /**
  36386. * Detaches the behavior from the mesh
  36387. */
  36388. detach(): void;
  36389. }
  36390. }
  36391. declare module BABYLON {
  36392. /**
  36393. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36394. */
  36395. export class FadeInOutBehavior implements Behavior<Mesh> {
  36396. /**
  36397. * Time in milliseconds to delay before fading in (Default: 0)
  36398. */
  36399. delay: number;
  36400. /**
  36401. * Time in milliseconds for the mesh to fade in (Default: 300)
  36402. */
  36403. fadeInTime: number;
  36404. private _millisecondsPerFrame;
  36405. private _hovered;
  36406. private _hoverValue;
  36407. private _ownerNode;
  36408. /**
  36409. * Instatiates the FadeInOutBehavior
  36410. */
  36411. constructor();
  36412. /**
  36413. * The name of the behavior
  36414. */
  36415. readonly name: string;
  36416. /**
  36417. * Initializes the behavior
  36418. */
  36419. init(): void;
  36420. /**
  36421. * Attaches the fade behavior on the passed in mesh
  36422. * @param ownerNode The mesh that will be faded in/out once attached
  36423. */
  36424. attach(ownerNode: Mesh): void;
  36425. /**
  36426. * Detaches the behavior from the mesh
  36427. */
  36428. detach(): void;
  36429. /**
  36430. * Triggers the mesh to begin fading in or out
  36431. * @param value if the object should fade in or out (true to fade in)
  36432. */
  36433. fadeIn(value: boolean): void;
  36434. private _update;
  36435. private _setAllVisibility;
  36436. }
  36437. }
  36438. declare module BABYLON {
  36439. /**
  36440. * Class containing a set of static utilities functions for managing Pivots
  36441. * @hidden
  36442. */
  36443. export class PivotTools {
  36444. private static _PivotCached;
  36445. private static _OldPivotPoint;
  36446. private static _PivotTranslation;
  36447. private static _PivotTmpVector;
  36448. /** @hidden */
  36449. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36450. /** @hidden */
  36451. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36452. }
  36453. }
  36454. declare module BABYLON {
  36455. /**
  36456. * Class containing static functions to help procedurally build meshes
  36457. */
  36458. export class PlaneBuilder {
  36459. /**
  36460. * Creates a plane mesh
  36461. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36462. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36463. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36465. * * 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
  36466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36467. * @param name defines the name of the mesh
  36468. * @param options defines the options used to create the mesh
  36469. * @param scene defines the hosting scene
  36470. * @returns the plane mesh
  36471. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36472. */
  36473. static CreatePlane(name: string, options: {
  36474. size?: number;
  36475. width?: number;
  36476. height?: number;
  36477. sideOrientation?: number;
  36478. frontUVs?: Vector4;
  36479. backUVs?: Vector4;
  36480. updatable?: boolean;
  36481. sourcePlane?: Plane;
  36482. }, scene?: Nullable<Scene>): Mesh;
  36483. }
  36484. }
  36485. declare module BABYLON {
  36486. /**
  36487. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36488. */
  36489. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36490. private static _AnyMouseID;
  36491. /**
  36492. * Abstract mesh the behavior is set on
  36493. */
  36494. attachedNode: AbstractMesh;
  36495. private _dragPlane;
  36496. private _scene;
  36497. private _pointerObserver;
  36498. private _beforeRenderObserver;
  36499. private static _planeScene;
  36500. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36501. /**
  36502. * 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)
  36503. */
  36504. maxDragAngle: number;
  36505. /**
  36506. * @hidden
  36507. */
  36508. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36509. /**
  36510. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36511. */
  36512. currentDraggingPointerID: number;
  36513. /**
  36514. * The last position where the pointer hit the drag plane in world space
  36515. */
  36516. lastDragPosition: Vector3;
  36517. /**
  36518. * If the behavior is currently in a dragging state
  36519. */
  36520. dragging: boolean;
  36521. /**
  36522. * 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)
  36523. */
  36524. dragDeltaRatio: number;
  36525. /**
  36526. * If the drag plane orientation should be updated during the dragging (Default: true)
  36527. */
  36528. updateDragPlane: boolean;
  36529. private _debugMode;
  36530. private _moving;
  36531. /**
  36532. * Fires each time the attached mesh is dragged with the pointer
  36533. * * delta between last drag position and current drag position in world space
  36534. * * dragDistance along the drag axis
  36535. * * dragPlaneNormal normal of the current drag plane used during the drag
  36536. * * dragPlanePoint in world space where the drag intersects the drag plane
  36537. */
  36538. onDragObservable: Observable<{
  36539. delta: Vector3;
  36540. dragPlanePoint: Vector3;
  36541. dragPlaneNormal: Vector3;
  36542. dragDistance: number;
  36543. pointerId: number;
  36544. }>;
  36545. /**
  36546. * Fires each time a drag begins (eg. mouse down on mesh)
  36547. */
  36548. onDragStartObservable: Observable<{
  36549. dragPlanePoint: Vector3;
  36550. pointerId: number;
  36551. }>;
  36552. /**
  36553. * Fires each time a drag ends (eg. mouse release after drag)
  36554. */
  36555. onDragEndObservable: Observable<{
  36556. dragPlanePoint: Vector3;
  36557. pointerId: number;
  36558. }>;
  36559. /**
  36560. * If the attached mesh should be moved when dragged
  36561. */
  36562. moveAttached: boolean;
  36563. /**
  36564. * If the drag behavior will react to drag events (Default: true)
  36565. */
  36566. enabled: boolean;
  36567. /**
  36568. * If pointer events should start and release the drag (Default: true)
  36569. */
  36570. startAndReleaseDragOnPointerEvents: boolean;
  36571. /**
  36572. * If camera controls should be detached during the drag
  36573. */
  36574. detachCameraControls: boolean;
  36575. /**
  36576. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36577. */
  36578. useObjectOrienationForDragging: boolean;
  36579. private _options;
  36580. /**
  36581. * Creates a pointer drag behavior that can be attached to a mesh
  36582. * @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)
  36583. */
  36584. constructor(options?: {
  36585. dragAxis?: Vector3;
  36586. dragPlaneNormal?: Vector3;
  36587. });
  36588. /**
  36589. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36590. */
  36591. validateDrag: (targetPosition: Vector3) => boolean;
  36592. /**
  36593. * The name of the behavior
  36594. */
  36595. readonly name: string;
  36596. /**
  36597. * Initializes the behavior
  36598. */
  36599. init(): void;
  36600. private _tmpVector;
  36601. private _alternatePickedPoint;
  36602. private _worldDragAxis;
  36603. private _targetPosition;
  36604. private _attachedElement;
  36605. /**
  36606. * Attaches the drag behavior the passed in mesh
  36607. * @param ownerNode The mesh that will be dragged around once attached
  36608. */
  36609. attach(ownerNode: AbstractMesh): void;
  36610. /**
  36611. * Force relase the drag action by code.
  36612. */
  36613. releaseDrag(): void;
  36614. private _startDragRay;
  36615. private _lastPointerRay;
  36616. /**
  36617. * Simulates the start of a pointer drag event on the behavior
  36618. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36619. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36620. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36621. */
  36622. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36623. private _startDrag;
  36624. private _dragDelta;
  36625. private _moveDrag;
  36626. private _pickWithRayOnDragPlane;
  36627. private _pointA;
  36628. private _pointB;
  36629. private _pointC;
  36630. private _lineA;
  36631. private _lineB;
  36632. private _localAxis;
  36633. private _lookAt;
  36634. private _updateDragPlanePosition;
  36635. /**
  36636. * Detaches the behavior from the mesh
  36637. */
  36638. detach(): void;
  36639. }
  36640. }
  36641. declare module BABYLON {
  36642. /**
  36643. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36644. */
  36645. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36646. private _dragBehaviorA;
  36647. private _dragBehaviorB;
  36648. private _startDistance;
  36649. private _initialScale;
  36650. private _targetScale;
  36651. private _ownerNode;
  36652. private _sceneRenderObserver;
  36653. /**
  36654. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36655. */
  36656. constructor();
  36657. /**
  36658. * The name of the behavior
  36659. */
  36660. readonly name: string;
  36661. /**
  36662. * Initializes the behavior
  36663. */
  36664. init(): void;
  36665. private _getCurrentDistance;
  36666. /**
  36667. * Attaches the scale behavior the passed in mesh
  36668. * @param ownerNode The mesh that will be scaled around once attached
  36669. */
  36670. attach(ownerNode: Mesh): void;
  36671. /**
  36672. * Detaches the behavior from the mesh
  36673. */
  36674. detach(): void;
  36675. }
  36676. }
  36677. declare module BABYLON {
  36678. /**
  36679. * 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
  36680. */
  36681. export class SixDofDragBehavior implements Behavior<Mesh> {
  36682. private static _virtualScene;
  36683. private _ownerNode;
  36684. private _sceneRenderObserver;
  36685. private _scene;
  36686. private _targetPosition;
  36687. private _virtualOriginMesh;
  36688. private _virtualDragMesh;
  36689. private _pointerObserver;
  36690. private _moving;
  36691. private _startingOrientation;
  36692. /**
  36693. * 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)
  36694. */
  36695. private zDragFactor;
  36696. /**
  36697. * If the object should rotate to face the drag origin
  36698. */
  36699. rotateDraggedObject: boolean;
  36700. /**
  36701. * If the behavior is currently in a dragging state
  36702. */
  36703. dragging: boolean;
  36704. /**
  36705. * 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)
  36706. */
  36707. dragDeltaRatio: number;
  36708. /**
  36709. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36710. */
  36711. currentDraggingPointerID: number;
  36712. /**
  36713. * If camera controls should be detached during the drag
  36714. */
  36715. detachCameraControls: boolean;
  36716. /**
  36717. * Fires each time a drag starts
  36718. */
  36719. onDragStartObservable: Observable<{}>;
  36720. /**
  36721. * Fires each time a drag ends (eg. mouse release after drag)
  36722. */
  36723. onDragEndObservable: Observable<{}>;
  36724. /**
  36725. * 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
  36726. */
  36727. constructor();
  36728. /**
  36729. * The name of the behavior
  36730. */
  36731. readonly name: string;
  36732. /**
  36733. * Initializes the behavior
  36734. */
  36735. init(): void;
  36736. /**
  36737. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36738. */
  36739. private readonly _pointerCamera;
  36740. /**
  36741. * Attaches the scale behavior the passed in mesh
  36742. * @param ownerNode The mesh that will be scaled around once attached
  36743. */
  36744. attach(ownerNode: Mesh): void;
  36745. /**
  36746. * Detaches the behavior from the mesh
  36747. */
  36748. detach(): void;
  36749. }
  36750. }
  36751. declare module BABYLON {
  36752. /**
  36753. * Class used to apply inverse kinematics to bones
  36754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36755. */
  36756. export class BoneIKController {
  36757. private static _tmpVecs;
  36758. private static _tmpQuat;
  36759. private static _tmpMats;
  36760. /**
  36761. * Gets or sets the target mesh
  36762. */
  36763. targetMesh: AbstractMesh;
  36764. /** Gets or sets the mesh used as pole */
  36765. poleTargetMesh: AbstractMesh;
  36766. /**
  36767. * Gets or sets the bone used as pole
  36768. */
  36769. poleTargetBone: Nullable<Bone>;
  36770. /**
  36771. * Gets or sets the target position
  36772. */
  36773. targetPosition: Vector3;
  36774. /**
  36775. * Gets or sets the pole target position
  36776. */
  36777. poleTargetPosition: Vector3;
  36778. /**
  36779. * Gets or sets the pole target local offset
  36780. */
  36781. poleTargetLocalOffset: Vector3;
  36782. /**
  36783. * Gets or sets the pole angle
  36784. */
  36785. poleAngle: number;
  36786. /**
  36787. * Gets or sets the mesh associated with the controller
  36788. */
  36789. mesh: AbstractMesh;
  36790. /**
  36791. * 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)
  36792. */
  36793. slerpAmount: number;
  36794. private _bone1Quat;
  36795. private _bone1Mat;
  36796. private _bone2Ang;
  36797. private _bone1;
  36798. private _bone2;
  36799. private _bone1Length;
  36800. private _bone2Length;
  36801. private _maxAngle;
  36802. private _maxReach;
  36803. private _rightHandedSystem;
  36804. private _bendAxis;
  36805. private _slerping;
  36806. private _adjustRoll;
  36807. /**
  36808. * Gets or sets maximum allowed angle
  36809. */
  36810. maxAngle: number;
  36811. /**
  36812. * Creates a new BoneIKController
  36813. * @param mesh defines the mesh to control
  36814. * @param bone defines the bone to control
  36815. * @param options defines options to set up the controller
  36816. */
  36817. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36818. targetMesh?: AbstractMesh;
  36819. poleTargetMesh?: AbstractMesh;
  36820. poleTargetBone?: Bone;
  36821. poleTargetLocalOffset?: Vector3;
  36822. poleAngle?: number;
  36823. bendAxis?: Vector3;
  36824. maxAngle?: number;
  36825. slerpAmount?: number;
  36826. });
  36827. private _setMaxAngle;
  36828. /**
  36829. * Force the controller to update the bones
  36830. */
  36831. update(): void;
  36832. }
  36833. }
  36834. declare module BABYLON {
  36835. /**
  36836. * Class used to make a bone look toward a point in space
  36837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36838. */
  36839. export class BoneLookController {
  36840. private static _tmpVecs;
  36841. private static _tmpQuat;
  36842. private static _tmpMats;
  36843. /**
  36844. * The target Vector3 that the bone will look at
  36845. */
  36846. target: Vector3;
  36847. /**
  36848. * The mesh that the bone is attached to
  36849. */
  36850. mesh: AbstractMesh;
  36851. /**
  36852. * The bone that will be looking to the target
  36853. */
  36854. bone: Bone;
  36855. /**
  36856. * The up axis of the coordinate system that is used when the bone is rotated
  36857. */
  36858. upAxis: Vector3;
  36859. /**
  36860. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36861. */
  36862. upAxisSpace: Space;
  36863. /**
  36864. * Used to make an adjustment to the yaw of the bone
  36865. */
  36866. adjustYaw: number;
  36867. /**
  36868. * Used to make an adjustment to the pitch of the bone
  36869. */
  36870. adjustPitch: number;
  36871. /**
  36872. * Used to make an adjustment to the roll of the bone
  36873. */
  36874. adjustRoll: number;
  36875. /**
  36876. * 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)
  36877. */
  36878. slerpAmount: number;
  36879. private _minYaw;
  36880. private _maxYaw;
  36881. private _minPitch;
  36882. private _maxPitch;
  36883. private _minYawSin;
  36884. private _minYawCos;
  36885. private _maxYawSin;
  36886. private _maxYawCos;
  36887. private _midYawConstraint;
  36888. private _minPitchTan;
  36889. private _maxPitchTan;
  36890. private _boneQuat;
  36891. private _slerping;
  36892. private _transformYawPitch;
  36893. private _transformYawPitchInv;
  36894. private _firstFrameSkipped;
  36895. private _yawRange;
  36896. private _fowardAxis;
  36897. /**
  36898. * Gets or sets the minimum yaw angle that the bone can look to
  36899. */
  36900. minYaw: number;
  36901. /**
  36902. * Gets or sets the maximum yaw angle that the bone can look to
  36903. */
  36904. maxYaw: number;
  36905. /**
  36906. * Gets or sets the minimum pitch angle that the bone can look to
  36907. */
  36908. minPitch: number;
  36909. /**
  36910. * Gets or sets the maximum pitch angle that the bone can look to
  36911. */
  36912. maxPitch: number;
  36913. /**
  36914. * Create a BoneLookController
  36915. * @param mesh the mesh that the bone belongs to
  36916. * @param bone the bone that will be looking to the target
  36917. * @param target the target Vector3 to look at
  36918. * @param options optional settings:
  36919. * * maxYaw: the maximum angle the bone will yaw to
  36920. * * minYaw: the minimum angle the bone will yaw to
  36921. * * maxPitch: the maximum angle the bone will pitch to
  36922. * * minPitch: the minimum angle the bone will yaw to
  36923. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36924. * * upAxis: the up axis of the coordinate system
  36925. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36926. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36927. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36928. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36929. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36930. * * adjustRoll: used to make an adjustment to the roll of the bone
  36931. **/
  36932. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36933. maxYaw?: number;
  36934. minYaw?: number;
  36935. maxPitch?: number;
  36936. minPitch?: number;
  36937. slerpAmount?: number;
  36938. upAxis?: Vector3;
  36939. upAxisSpace?: Space;
  36940. yawAxis?: Vector3;
  36941. pitchAxis?: Vector3;
  36942. adjustYaw?: number;
  36943. adjustPitch?: number;
  36944. adjustRoll?: number;
  36945. });
  36946. /**
  36947. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36948. */
  36949. update(): void;
  36950. private _getAngleDiff;
  36951. private _getAngleBetween;
  36952. private _isAngleBetween;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * Manage the gamepad inputs to control an arc rotate camera.
  36958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36959. */
  36960. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36961. /**
  36962. * Defines the camera the input is attached to.
  36963. */
  36964. camera: ArcRotateCamera;
  36965. /**
  36966. * Defines the gamepad the input is gathering event from.
  36967. */
  36968. gamepad: Nullable<Gamepad>;
  36969. /**
  36970. * Defines the gamepad rotation sensiblity.
  36971. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36972. */
  36973. gamepadRotationSensibility: number;
  36974. /**
  36975. * Defines the gamepad move sensiblity.
  36976. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36977. */
  36978. gamepadMoveSensibility: number;
  36979. private _onGamepadConnectedObserver;
  36980. private _onGamepadDisconnectedObserver;
  36981. /**
  36982. * Attach the input controls to a specific dom element to get the input from.
  36983. * @param element Defines the element the controls should be listened from
  36984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36985. */
  36986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36987. /**
  36988. * Detach the current controls from the specified dom element.
  36989. * @param element Defines the element to stop listening the inputs from
  36990. */
  36991. detachControl(element: Nullable<HTMLElement>): void;
  36992. /**
  36993. * Update the current camera state depending on the inputs that have been used this frame.
  36994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36995. */
  36996. checkInputs(): void;
  36997. /**
  36998. * Gets the class name of the current intput.
  36999. * @returns the class name
  37000. */
  37001. getClassName(): string;
  37002. /**
  37003. * Get the friendly name associated with the input class.
  37004. * @returns the input friendly name
  37005. */
  37006. getSimpleName(): string;
  37007. }
  37008. }
  37009. declare module BABYLON {
  37010. interface ArcRotateCameraInputsManager {
  37011. /**
  37012. * Add orientation input support to the input manager.
  37013. * @returns the current input manager
  37014. */
  37015. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37016. }
  37017. /**
  37018. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37020. */
  37021. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37022. /**
  37023. * Defines the camera the input is attached to.
  37024. */
  37025. camera: ArcRotateCamera;
  37026. /**
  37027. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37028. */
  37029. alphaCorrection: number;
  37030. /**
  37031. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37032. */
  37033. gammaCorrection: number;
  37034. private _alpha;
  37035. private _gamma;
  37036. private _dirty;
  37037. private _deviceOrientationHandler;
  37038. /**
  37039. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37040. */
  37041. constructor();
  37042. /**
  37043. * Attach the input controls to a specific dom element to get the input from.
  37044. * @param element Defines the element the controls should be listened from
  37045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37046. */
  37047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37048. /** @hidden */
  37049. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37050. /**
  37051. * Update the current camera state depending on the inputs that have been used this frame.
  37052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37053. */
  37054. checkInputs(): void;
  37055. /**
  37056. * Detach the current controls from the specified dom element.
  37057. * @param element Defines the element to stop listening the inputs from
  37058. */
  37059. detachControl(element: Nullable<HTMLElement>): void;
  37060. /**
  37061. * Gets the class name of the current intput.
  37062. * @returns the class name
  37063. */
  37064. getClassName(): string;
  37065. /**
  37066. * Get the friendly name associated with the input class.
  37067. * @returns the input friendly name
  37068. */
  37069. getSimpleName(): string;
  37070. }
  37071. }
  37072. declare module BABYLON {
  37073. /**
  37074. * Listen to mouse events to control the camera.
  37075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37076. */
  37077. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37078. /**
  37079. * Defines the camera the input is attached to.
  37080. */
  37081. camera: FlyCamera;
  37082. /**
  37083. * Defines if touch is enabled. (Default is true.)
  37084. */
  37085. touchEnabled: boolean;
  37086. /**
  37087. * Defines the buttons associated with the input to handle camera rotation.
  37088. */
  37089. buttons: number[];
  37090. /**
  37091. * Assign buttons for Yaw control.
  37092. */
  37093. buttonsYaw: number[];
  37094. /**
  37095. * Assign buttons for Pitch control.
  37096. */
  37097. buttonsPitch: number[];
  37098. /**
  37099. * Assign buttons for Roll control.
  37100. */
  37101. buttonsRoll: number[];
  37102. /**
  37103. * Detect if any button is being pressed while mouse is moved.
  37104. * -1 = Mouse locked.
  37105. * 0 = Left button.
  37106. * 1 = Middle Button.
  37107. * 2 = Right Button.
  37108. */
  37109. activeButton: number;
  37110. /**
  37111. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37112. * Higher values reduce its sensitivity.
  37113. */
  37114. angularSensibility: number;
  37115. private _mousemoveCallback;
  37116. private _observer;
  37117. private _rollObserver;
  37118. private previousPosition;
  37119. private noPreventDefault;
  37120. private element;
  37121. /**
  37122. * Listen to mouse events to control the camera.
  37123. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37125. */
  37126. constructor(touchEnabled?: boolean);
  37127. /**
  37128. * Attach the mouse control to the HTML DOM element.
  37129. * @param element Defines the element that listens to the input events.
  37130. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current input.
  37140. * @returns the class name.
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input's friendly name.
  37146. */
  37147. getSimpleName(): string;
  37148. private _pointerInput;
  37149. private _onMouseMove;
  37150. /**
  37151. * Rotate camera by mouse offset.
  37152. */
  37153. private rotateCamera;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. /**
  37158. * Default Inputs manager for the FlyCamera.
  37159. * It groups all the default supported inputs for ease of use.
  37160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37161. */
  37162. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37163. /**
  37164. * Instantiates a new FlyCameraInputsManager.
  37165. * @param camera Defines the camera the inputs belong to.
  37166. */
  37167. constructor(camera: FlyCamera);
  37168. /**
  37169. * Add keyboard input support to the input manager.
  37170. * @returns the new FlyCameraKeyboardMoveInput().
  37171. */
  37172. addKeyboard(): FlyCameraInputsManager;
  37173. /**
  37174. * Add mouse input support to the input manager.
  37175. * @param touchEnabled Enable touch screen support.
  37176. * @returns the new FlyCameraMouseInput().
  37177. */
  37178. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37179. }
  37180. }
  37181. declare module BABYLON {
  37182. /**
  37183. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37184. * such as in a 3D Space Shooter or a Flight Simulator.
  37185. */
  37186. export class FlyCamera extends TargetCamera {
  37187. /**
  37188. * Define the collision ellipsoid of the camera.
  37189. * This is helpful for simulating a camera body, like a player's body.
  37190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37191. */
  37192. ellipsoid: Vector3;
  37193. /**
  37194. * Define an offset for the position of the ellipsoid around the camera.
  37195. * This can be helpful if the camera is attached away from the player's body center,
  37196. * such as at its head.
  37197. */
  37198. ellipsoidOffset: Vector3;
  37199. /**
  37200. * Enable or disable collisions of the camera with the rest of the scene objects.
  37201. */
  37202. checkCollisions: boolean;
  37203. /**
  37204. * Enable or disable gravity on the camera.
  37205. */
  37206. applyGravity: boolean;
  37207. /**
  37208. * Define the current direction the camera is moving to.
  37209. */
  37210. cameraDirection: Vector3;
  37211. /**
  37212. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37213. * This overrides and empties cameraRotation.
  37214. */
  37215. rotationQuaternion: Quaternion;
  37216. /**
  37217. * Track Roll to maintain the wanted Rolling when looking around.
  37218. */
  37219. _trackRoll: number;
  37220. /**
  37221. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37222. */
  37223. rollCorrect: number;
  37224. /**
  37225. * Mimic a banked turn, Rolling the camera when Yawing.
  37226. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37227. */
  37228. bankedTurn: boolean;
  37229. /**
  37230. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37231. */
  37232. bankedTurnLimit: number;
  37233. /**
  37234. * Value of 0 disables the banked Roll.
  37235. * Value of 1 is equal to the Yaw angle in radians.
  37236. */
  37237. bankedTurnMultiplier: number;
  37238. /**
  37239. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37240. */
  37241. inputs: FlyCameraInputsManager;
  37242. /**
  37243. * Gets the input sensibility for mouse input.
  37244. * Higher values reduce sensitivity.
  37245. */
  37246. /**
  37247. * Sets the input sensibility for a mouse input.
  37248. * Higher values reduce sensitivity.
  37249. */
  37250. angularSensibility: number;
  37251. /**
  37252. * Get the keys for camera movement forward.
  37253. */
  37254. /**
  37255. * Set the keys for camera movement forward.
  37256. */
  37257. keysForward: number[];
  37258. /**
  37259. * Get the keys for camera movement backward.
  37260. */
  37261. keysBackward: number[];
  37262. /**
  37263. * Get the keys for camera movement up.
  37264. */
  37265. /**
  37266. * Set the keys for camera movement up.
  37267. */
  37268. keysUp: number[];
  37269. /**
  37270. * Get the keys for camera movement down.
  37271. */
  37272. /**
  37273. * Set the keys for camera movement down.
  37274. */
  37275. keysDown: number[];
  37276. /**
  37277. * Get the keys for camera movement left.
  37278. */
  37279. /**
  37280. * Set the keys for camera movement left.
  37281. */
  37282. keysLeft: number[];
  37283. /**
  37284. * Set the keys for camera movement right.
  37285. */
  37286. /**
  37287. * Set the keys for camera movement right.
  37288. */
  37289. keysRight: number[];
  37290. /**
  37291. * Event raised when the camera collides with a mesh in the scene.
  37292. */
  37293. onCollide: (collidedMesh: AbstractMesh) => void;
  37294. private _collider;
  37295. private _needMoveForGravity;
  37296. private _oldPosition;
  37297. private _diffPosition;
  37298. private _newPosition;
  37299. /** @hidden */
  37300. _localDirection: Vector3;
  37301. /** @hidden */
  37302. _transformedDirection: Vector3;
  37303. /**
  37304. * Instantiates a FlyCamera.
  37305. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37306. * such as in a 3D Space Shooter or a Flight Simulator.
  37307. * @param name Define the name of the camera in the scene.
  37308. * @param position Define the starting position of the camera in the scene.
  37309. * @param scene Define the scene the camera belongs to.
  37310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37311. */
  37312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37313. /**
  37314. * Attach a control to the HTML DOM element.
  37315. * @param element Defines the element that listens to the input events.
  37316. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37317. */
  37318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37319. /**
  37320. * Detach a control from the HTML DOM element.
  37321. * The camera will stop reacting to that input.
  37322. * @param element Defines the element that listens to the input events.
  37323. */
  37324. detachControl(element: HTMLElement): void;
  37325. private _collisionMask;
  37326. /**
  37327. * Get the mask that the camera ignores in collision events.
  37328. */
  37329. /**
  37330. * Set the mask that the camera ignores in collision events.
  37331. */
  37332. collisionMask: number;
  37333. /** @hidden */
  37334. _collideWithWorld(displacement: Vector3): void;
  37335. /** @hidden */
  37336. private _onCollisionPositionChange;
  37337. /** @hidden */
  37338. _checkInputs(): void;
  37339. /** @hidden */
  37340. _decideIfNeedsToMove(): boolean;
  37341. /** @hidden */
  37342. _updatePosition(): void;
  37343. /**
  37344. * Restore the Roll to its target value at the rate specified.
  37345. * @param rate - Higher means slower restoring.
  37346. * @hidden
  37347. */
  37348. restoreRoll(rate: number): void;
  37349. /**
  37350. * Destroy the camera and release the current resources held by it.
  37351. */
  37352. dispose(): void;
  37353. /**
  37354. * Get the current object class name.
  37355. * @returns the class name.
  37356. */
  37357. getClassName(): string;
  37358. }
  37359. }
  37360. declare module BABYLON {
  37361. /**
  37362. * Listen to keyboard events to control the camera.
  37363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37364. */
  37365. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37366. /**
  37367. * Defines the camera the input is attached to.
  37368. */
  37369. camera: FlyCamera;
  37370. /**
  37371. * The list of keyboard keys used to control the forward move of the camera.
  37372. */
  37373. keysForward: number[];
  37374. /**
  37375. * The list of keyboard keys used to control the backward move of the camera.
  37376. */
  37377. keysBackward: number[];
  37378. /**
  37379. * The list of keyboard keys used to control the forward move of the camera.
  37380. */
  37381. keysUp: number[];
  37382. /**
  37383. * The list of keyboard keys used to control the backward move of the camera.
  37384. */
  37385. keysDown: number[];
  37386. /**
  37387. * The list of keyboard keys used to control the right strafe move of the camera.
  37388. */
  37389. keysRight: number[];
  37390. /**
  37391. * The list of keyboard keys used to control the left strafe move of the camera.
  37392. */
  37393. keysLeft: number[];
  37394. private _keys;
  37395. private _onCanvasBlurObserver;
  37396. private _onKeyboardObserver;
  37397. private _engine;
  37398. private _scene;
  37399. /**
  37400. * Attach the input controls to a specific dom element to get the input from.
  37401. * @param element Defines the element the controls should be listened from
  37402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37403. */
  37404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37405. /**
  37406. * Detach the current controls from the specified dom element.
  37407. * @param element Defines the element to stop listening the inputs from
  37408. */
  37409. detachControl(element: Nullable<HTMLElement>): void;
  37410. /**
  37411. * Gets the class name of the current intput.
  37412. * @returns the class name
  37413. */
  37414. getClassName(): string;
  37415. /** @hidden */
  37416. _onLostFocus(e: FocusEvent): void;
  37417. /**
  37418. * Get the friendly name associated with the input class.
  37419. * @returns the input friendly name
  37420. */
  37421. getSimpleName(): string;
  37422. /**
  37423. * Update the current camera state depending on the inputs that have been used this frame.
  37424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37425. */
  37426. checkInputs(): void;
  37427. }
  37428. }
  37429. declare module BABYLON {
  37430. /**
  37431. * Manage the mouse wheel inputs to control a follow camera.
  37432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37433. */
  37434. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37435. /**
  37436. * Defines the camera the input is attached to.
  37437. */
  37438. camera: FollowCamera;
  37439. /**
  37440. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37441. */
  37442. axisControlRadius: boolean;
  37443. /**
  37444. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37445. */
  37446. axisControlHeight: boolean;
  37447. /**
  37448. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37449. */
  37450. axisControlRotation: boolean;
  37451. /**
  37452. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37453. * relation to mouseWheel events.
  37454. */
  37455. wheelPrecision: number;
  37456. /**
  37457. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37458. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37459. */
  37460. wheelDeltaPercentage: number;
  37461. private _wheel;
  37462. private _observer;
  37463. /**
  37464. * Attach the input controls to a specific dom element to get the input from.
  37465. * @param element Defines the element the controls should be listened from
  37466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37467. */
  37468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37469. /**
  37470. * Detach the current controls from the specified dom element.
  37471. * @param element Defines the element to stop listening the inputs from
  37472. */
  37473. detachControl(element: Nullable<HTMLElement>): void;
  37474. /**
  37475. * Gets the class name of the current intput.
  37476. * @returns the class name
  37477. */
  37478. getClassName(): string;
  37479. /**
  37480. * Get the friendly name associated with the input class.
  37481. * @returns the input friendly name
  37482. */
  37483. getSimpleName(): string;
  37484. }
  37485. }
  37486. declare module BABYLON {
  37487. /**
  37488. * Manage the pointers inputs to control an follow camera.
  37489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37490. */
  37491. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37492. /**
  37493. * Defines the camera the input is attached to.
  37494. */
  37495. camera: FollowCamera;
  37496. /**
  37497. * Gets the class name of the current input.
  37498. * @returns the class name
  37499. */
  37500. getClassName(): string;
  37501. /**
  37502. * Defines the pointer angular sensibility along the X axis or how fast is
  37503. * the camera rotating.
  37504. * A negative number will reverse the axis direction.
  37505. */
  37506. angularSensibilityX: number;
  37507. /**
  37508. * Defines the pointer angular sensibility along the Y axis or how fast is
  37509. * the camera rotating.
  37510. * A negative number will reverse the axis direction.
  37511. */
  37512. angularSensibilityY: number;
  37513. /**
  37514. * Defines the pointer pinch precision or how fast is the camera zooming.
  37515. * A negative number will reverse the axis direction.
  37516. */
  37517. pinchPrecision: number;
  37518. /**
  37519. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37520. * from 0.
  37521. * It defines the percentage of current camera.radius to use as delta when
  37522. * pinch zoom is used.
  37523. */
  37524. pinchDeltaPercentage: number;
  37525. /**
  37526. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37527. */
  37528. axisXControlRadius: boolean;
  37529. /**
  37530. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37531. */
  37532. axisXControlHeight: boolean;
  37533. /**
  37534. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37535. */
  37536. axisXControlRotation: boolean;
  37537. /**
  37538. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37539. */
  37540. axisYControlRadius: boolean;
  37541. /**
  37542. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37543. */
  37544. axisYControlHeight: boolean;
  37545. /**
  37546. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37547. */
  37548. axisYControlRotation: boolean;
  37549. /**
  37550. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37551. */
  37552. axisPinchControlRadius: boolean;
  37553. /**
  37554. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37555. */
  37556. axisPinchControlHeight: boolean;
  37557. /**
  37558. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37559. */
  37560. axisPinchControlRotation: boolean;
  37561. /**
  37562. * Log error messages if basic misconfiguration has occurred.
  37563. */
  37564. warningEnable: boolean;
  37565. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37566. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37567. private _warningCounter;
  37568. private _warning;
  37569. }
  37570. }
  37571. declare module BABYLON {
  37572. /**
  37573. * Default Inputs manager for the FollowCamera.
  37574. * It groups all the default supported inputs for ease of use.
  37575. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37576. */
  37577. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37578. /**
  37579. * Instantiates a new FollowCameraInputsManager.
  37580. * @param camera Defines the camera the inputs belong to
  37581. */
  37582. constructor(camera: FollowCamera);
  37583. /**
  37584. * Add keyboard input support to the input manager.
  37585. * @returns the current input manager
  37586. */
  37587. addKeyboard(): FollowCameraInputsManager;
  37588. /**
  37589. * Add mouse wheel input support to the input manager.
  37590. * @returns the current input manager
  37591. */
  37592. addMouseWheel(): FollowCameraInputsManager;
  37593. /**
  37594. * Add pointers input support to the input manager.
  37595. * @returns the current input manager
  37596. */
  37597. addPointers(): FollowCameraInputsManager;
  37598. /**
  37599. * Add orientation input support to the input manager.
  37600. * @returns the current input manager
  37601. */
  37602. addVRDeviceOrientation(): FollowCameraInputsManager;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37608. * an arc rotate version arcFollowCamera are available.
  37609. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37610. */
  37611. export class FollowCamera extends TargetCamera {
  37612. /**
  37613. * Distance the follow camera should follow an object at
  37614. */
  37615. radius: number;
  37616. /**
  37617. * Minimum allowed distance of the camera to the axis of rotation
  37618. * (The camera can not get closer).
  37619. * This can help limiting how the Camera is able to move in the scene.
  37620. */
  37621. lowerRadiusLimit: Nullable<number>;
  37622. /**
  37623. * Maximum allowed distance of the camera to the axis of rotation
  37624. * (The camera can not get further).
  37625. * This can help limiting how the Camera is able to move in the scene.
  37626. */
  37627. upperRadiusLimit: Nullable<number>;
  37628. /**
  37629. * Define a rotation offset between the camera and the object it follows
  37630. */
  37631. rotationOffset: number;
  37632. /**
  37633. * Minimum allowed angle to camera position relative to target object.
  37634. * This can help limiting how the Camera is able to move in the scene.
  37635. */
  37636. lowerRotationOffsetLimit: Nullable<number>;
  37637. /**
  37638. * Maximum allowed angle to camera position relative to target object.
  37639. * This can help limiting how the Camera is able to move in the scene.
  37640. */
  37641. upperRotationOffsetLimit: Nullable<number>;
  37642. /**
  37643. * Define a height offset between the camera and the object it follows.
  37644. * It can help following an object from the top (like a car chaing a plane)
  37645. */
  37646. heightOffset: number;
  37647. /**
  37648. * Minimum allowed height of camera position relative to target object.
  37649. * This can help limiting how the Camera is able to move in the scene.
  37650. */
  37651. lowerHeightOffsetLimit: Nullable<number>;
  37652. /**
  37653. * Maximum allowed height of camera position relative to target object.
  37654. * This can help limiting how the Camera is able to move in the scene.
  37655. */
  37656. upperHeightOffsetLimit: Nullable<number>;
  37657. /**
  37658. * Define how fast the camera can accelerate to follow it s target.
  37659. */
  37660. cameraAcceleration: number;
  37661. /**
  37662. * Define the speed limit of the camera following an object.
  37663. */
  37664. maxCameraSpeed: number;
  37665. /**
  37666. * Define the target of the camera.
  37667. */
  37668. lockedTarget: Nullable<AbstractMesh>;
  37669. /**
  37670. * Defines the input associated with the camera.
  37671. */
  37672. inputs: FollowCameraInputsManager;
  37673. /**
  37674. * Instantiates the follow camera.
  37675. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37676. * @param name Define the name of the camera in the scene
  37677. * @param position Define the position of the camera
  37678. * @param scene Define the scene the camera belong to
  37679. * @param lockedTarget Define the target of the camera
  37680. */
  37681. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37682. private _follow;
  37683. /**
  37684. * Attached controls to the current camera.
  37685. * @param element Defines the element the controls should be listened from
  37686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37687. */
  37688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37689. /**
  37690. * Detach the current controls from the camera.
  37691. * The camera will stop reacting to inputs.
  37692. * @param element Defines the element to stop listening the inputs from
  37693. */
  37694. detachControl(element: HTMLElement): void;
  37695. /** @hidden */
  37696. _checkInputs(): void;
  37697. private _checkLimits;
  37698. /**
  37699. * Gets the camera class name.
  37700. * @returns the class name
  37701. */
  37702. getClassName(): string;
  37703. }
  37704. /**
  37705. * Arc Rotate version of the follow camera.
  37706. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37707. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37708. */
  37709. export class ArcFollowCamera extends TargetCamera {
  37710. /** The longitudinal angle of the camera */
  37711. alpha: number;
  37712. /** The latitudinal angle of the camera */
  37713. beta: number;
  37714. /** The radius of the camera from its target */
  37715. radius: number;
  37716. /** Define the camera target (the messh it should follow) */
  37717. target: Nullable<AbstractMesh>;
  37718. private _cartesianCoordinates;
  37719. /**
  37720. * Instantiates a new ArcFollowCamera
  37721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37722. * @param name Define the name of the camera
  37723. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37724. * @param beta Define the rotation angle of the camera around the elevation axis
  37725. * @param radius Define the radius of the camera from its target point
  37726. * @param target Define the target of the camera
  37727. * @param scene Define the scene the camera belongs to
  37728. */
  37729. constructor(name: string,
  37730. /** The longitudinal angle of the camera */
  37731. alpha: number,
  37732. /** The latitudinal angle of the camera */
  37733. beta: number,
  37734. /** The radius of the camera from its target */
  37735. radius: number,
  37736. /** Define the camera target (the messh it should follow) */
  37737. target: Nullable<AbstractMesh>, scene: Scene);
  37738. private _follow;
  37739. /** @hidden */
  37740. _checkInputs(): void;
  37741. /**
  37742. * Returns the class name of the object.
  37743. * It is mostly used internally for serialization purposes.
  37744. */
  37745. getClassName(): string;
  37746. }
  37747. }
  37748. declare module BABYLON {
  37749. /**
  37750. * Manage the keyboard inputs to control the movement of a follow camera.
  37751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37752. */
  37753. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37754. /**
  37755. * Defines the camera the input is attached to.
  37756. */
  37757. camera: FollowCamera;
  37758. /**
  37759. * Defines the list of key codes associated with the up action (increase heightOffset)
  37760. */
  37761. keysHeightOffsetIncr: number[];
  37762. /**
  37763. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37764. */
  37765. keysHeightOffsetDecr: number[];
  37766. /**
  37767. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37768. */
  37769. keysHeightOffsetModifierAlt: boolean;
  37770. /**
  37771. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37772. */
  37773. keysHeightOffsetModifierCtrl: boolean;
  37774. /**
  37775. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37776. */
  37777. keysHeightOffsetModifierShift: boolean;
  37778. /**
  37779. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37780. */
  37781. keysRotationOffsetIncr: number[];
  37782. /**
  37783. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37784. */
  37785. keysRotationOffsetDecr: number[];
  37786. /**
  37787. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37788. */
  37789. keysRotationOffsetModifierAlt: boolean;
  37790. /**
  37791. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37792. */
  37793. keysRotationOffsetModifierCtrl: boolean;
  37794. /**
  37795. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37796. */
  37797. keysRotationOffsetModifierShift: boolean;
  37798. /**
  37799. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37800. */
  37801. keysRadiusIncr: number[];
  37802. /**
  37803. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37804. */
  37805. keysRadiusDecr: number[];
  37806. /**
  37807. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37808. */
  37809. keysRadiusModifierAlt: boolean;
  37810. /**
  37811. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37812. */
  37813. keysRadiusModifierCtrl: boolean;
  37814. /**
  37815. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37816. */
  37817. keysRadiusModifierShift: boolean;
  37818. /**
  37819. * Defines the rate of change of heightOffset.
  37820. */
  37821. heightSensibility: number;
  37822. /**
  37823. * Defines the rate of change of rotationOffset.
  37824. */
  37825. rotationSensibility: number;
  37826. /**
  37827. * Defines the rate of change of radius.
  37828. */
  37829. radiusSensibility: number;
  37830. private _keys;
  37831. private _ctrlPressed;
  37832. private _altPressed;
  37833. private _shiftPressed;
  37834. private _onCanvasBlurObserver;
  37835. private _onKeyboardObserver;
  37836. private _engine;
  37837. private _scene;
  37838. /**
  37839. * Attach the input controls to a specific dom element to get the input from.
  37840. * @param element Defines the element the controls should be listened from
  37841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37842. */
  37843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37844. /**
  37845. * Detach the current controls from the specified dom element.
  37846. * @param element Defines the element to stop listening the inputs from
  37847. */
  37848. detachControl(element: Nullable<HTMLElement>): void;
  37849. /**
  37850. * Update the current camera state depending on the inputs that have been used this frame.
  37851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37852. */
  37853. checkInputs(): void;
  37854. /**
  37855. * Gets the class name of the current input.
  37856. * @returns the class name
  37857. */
  37858. getClassName(): string;
  37859. /**
  37860. * Get the friendly name associated with the input class.
  37861. * @returns the input friendly name
  37862. */
  37863. getSimpleName(): string;
  37864. /**
  37865. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37866. * allow modification of the heightOffset value.
  37867. */
  37868. private _modifierHeightOffset;
  37869. /**
  37870. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37871. * allow modification of the rotationOffset value.
  37872. */
  37873. private _modifierRotationOffset;
  37874. /**
  37875. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37876. * allow modification of the radius value.
  37877. */
  37878. private _modifierRadius;
  37879. }
  37880. }
  37881. declare module BABYLON {
  37882. interface FreeCameraInputsManager {
  37883. /**
  37884. * @hidden
  37885. */
  37886. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37887. /**
  37888. * Add orientation input support to the input manager.
  37889. * @returns the current input manager
  37890. */
  37891. addDeviceOrientation(): FreeCameraInputsManager;
  37892. }
  37893. /**
  37894. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37895. * Screen rotation is taken into account.
  37896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37897. */
  37898. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37899. private _camera;
  37900. private _screenOrientationAngle;
  37901. private _constantTranform;
  37902. private _screenQuaternion;
  37903. private _alpha;
  37904. private _beta;
  37905. private _gamma;
  37906. /**
  37907. * Can be used to detect if a device orientation sensor is availible on a device
  37908. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37909. * @returns a promise that will resolve on orientation change
  37910. */
  37911. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37912. /**
  37913. * @hidden
  37914. */
  37915. _onDeviceOrientationChangedObservable: Observable<void>;
  37916. /**
  37917. * Instantiates a new input
  37918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37919. */
  37920. constructor();
  37921. /**
  37922. * Define the camera controlled by the input.
  37923. */
  37924. camera: FreeCamera;
  37925. /**
  37926. * Attach the input controls to a specific dom element to get the input from.
  37927. * @param element Defines the element the controls should be listened from
  37928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37929. */
  37930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37931. private _orientationChanged;
  37932. private _deviceOrientation;
  37933. /**
  37934. * Detach the current controls from the specified dom element.
  37935. * @param element Defines the element to stop listening the inputs from
  37936. */
  37937. detachControl(element: Nullable<HTMLElement>): void;
  37938. /**
  37939. * Update the current camera state depending on the inputs that have been used this frame.
  37940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37941. */
  37942. checkInputs(): void;
  37943. /**
  37944. * Gets the class name of the current intput.
  37945. * @returns the class name
  37946. */
  37947. getClassName(): string;
  37948. /**
  37949. * Get the friendly name associated with the input class.
  37950. * @returns the input friendly name
  37951. */
  37952. getSimpleName(): string;
  37953. }
  37954. }
  37955. declare module BABYLON {
  37956. /**
  37957. * Manage the gamepad inputs to control a free camera.
  37958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37959. */
  37960. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37961. /**
  37962. * Define the camera the input is attached to.
  37963. */
  37964. camera: FreeCamera;
  37965. /**
  37966. * Define the Gamepad controlling the input
  37967. */
  37968. gamepad: Nullable<Gamepad>;
  37969. /**
  37970. * Defines the gamepad rotation sensiblity.
  37971. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37972. */
  37973. gamepadAngularSensibility: number;
  37974. /**
  37975. * Defines the gamepad move sensiblity.
  37976. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37977. */
  37978. gamepadMoveSensibility: number;
  37979. private _onGamepadConnectedObserver;
  37980. private _onGamepadDisconnectedObserver;
  37981. private _cameraTransform;
  37982. private _deltaTransform;
  37983. private _vector3;
  37984. private _vector2;
  37985. /**
  37986. * Attach the input controls to a specific dom element to get the input from.
  37987. * @param element Defines the element the controls should be listened from
  37988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37989. */
  37990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37991. /**
  37992. * Detach the current controls from the specified dom element.
  37993. * @param element Defines the element to stop listening the inputs from
  37994. */
  37995. detachControl(element: Nullable<HTMLElement>): void;
  37996. /**
  37997. * Update the current camera state depending on the inputs that have been used this frame.
  37998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37999. */
  38000. checkInputs(): void;
  38001. /**
  38002. * Gets the class name of the current intput.
  38003. * @returns the class name
  38004. */
  38005. getClassName(): string;
  38006. /**
  38007. * Get the friendly name associated with the input class.
  38008. * @returns the input friendly name
  38009. */
  38010. getSimpleName(): string;
  38011. }
  38012. }
  38013. declare module BABYLON {
  38014. /**
  38015. * Defines the potential axis of a Joystick
  38016. */
  38017. export enum JoystickAxis {
  38018. /** X axis */
  38019. X = 0,
  38020. /** Y axis */
  38021. Y = 1,
  38022. /** Z axis */
  38023. Z = 2
  38024. }
  38025. /**
  38026. * Class used to define virtual joystick (used in touch mode)
  38027. */
  38028. export class VirtualJoystick {
  38029. /**
  38030. * Gets or sets a boolean indicating that left and right values must be inverted
  38031. */
  38032. reverseLeftRight: boolean;
  38033. /**
  38034. * Gets or sets a boolean indicating that up and down values must be inverted
  38035. */
  38036. reverseUpDown: boolean;
  38037. /**
  38038. * Gets the offset value for the position (ie. the change of the position value)
  38039. */
  38040. deltaPosition: Vector3;
  38041. /**
  38042. * Gets a boolean indicating if the virtual joystick was pressed
  38043. */
  38044. pressed: boolean;
  38045. /**
  38046. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38047. */
  38048. static Canvas: Nullable<HTMLCanvasElement>;
  38049. private static _globalJoystickIndex;
  38050. private static vjCanvasContext;
  38051. private static vjCanvasWidth;
  38052. private static vjCanvasHeight;
  38053. private static halfWidth;
  38054. private _action;
  38055. private _axisTargetedByLeftAndRight;
  38056. private _axisTargetedByUpAndDown;
  38057. private _joystickSensibility;
  38058. private _inversedSensibility;
  38059. private _joystickPointerID;
  38060. private _joystickColor;
  38061. private _joystickPointerPos;
  38062. private _joystickPreviousPointerPos;
  38063. private _joystickPointerStartPos;
  38064. private _deltaJoystickVector;
  38065. private _leftJoystick;
  38066. private _touches;
  38067. private _onPointerDownHandlerRef;
  38068. private _onPointerMoveHandlerRef;
  38069. private _onPointerUpHandlerRef;
  38070. private _onResize;
  38071. /**
  38072. * Creates a new virtual joystick
  38073. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38074. */
  38075. constructor(leftJoystick?: boolean);
  38076. /**
  38077. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38078. * @param newJoystickSensibility defines the new sensibility
  38079. */
  38080. setJoystickSensibility(newJoystickSensibility: number): void;
  38081. private _onPointerDown;
  38082. private _onPointerMove;
  38083. private _onPointerUp;
  38084. /**
  38085. * Change the color of the virtual joystick
  38086. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38087. */
  38088. setJoystickColor(newColor: string): void;
  38089. /**
  38090. * Defines a callback to call when the joystick is touched
  38091. * @param action defines the callback
  38092. */
  38093. setActionOnTouch(action: () => any): void;
  38094. /**
  38095. * Defines which axis you'd like to control for left & right
  38096. * @param axis defines the axis to use
  38097. */
  38098. setAxisForLeftRight(axis: JoystickAxis): void;
  38099. /**
  38100. * Defines which axis you'd like to control for up & down
  38101. * @param axis defines the axis to use
  38102. */
  38103. setAxisForUpDown(axis: JoystickAxis): void;
  38104. private _drawVirtualJoystick;
  38105. /**
  38106. * Release internal HTML canvas
  38107. */
  38108. releaseCanvas(): void;
  38109. }
  38110. }
  38111. declare module BABYLON {
  38112. interface FreeCameraInputsManager {
  38113. /**
  38114. * Add virtual joystick input support to the input manager.
  38115. * @returns the current input manager
  38116. */
  38117. addVirtualJoystick(): FreeCameraInputsManager;
  38118. }
  38119. /**
  38120. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38122. */
  38123. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38124. /**
  38125. * Defines the camera the input is attached to.
  38126. */
  38127. camera: FreeCamera;
  38128. private _leftjoystick;
  38129. private _rightjoystick;
  38130. /**
  38131. * Gets the left stick of the virtual joystick.
  38132. * @returns The virtual Joystick
  38133. */
  38134. getLeftJoystick(): VirtualJoystick;
  38135. /**
  38136. * Gets the right stick of the virtual joystick.
  38137. * @returns The virtual Joystick
  38138. */
  38139. getRightJoystick(): VirtualJoystick;
  38140. /**
  38141. * Update the current camera state depending on the inputs that have been used this frame.
  38142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38143. */
  38144. checkInputs(): void;
  38145. /**
  38146. * Attach the input controls to a specific dom element to get the input from.
  38147. * @param element Defines the element the controls should be listened from
  38148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38149. */
  38150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38151. /**
  38152. * Detach the current controls from the specified dom element.
  38153. * @param element Defines the element to stop listening the inputs from
  38154. */
  38155. detachControl(element: Nullable<HTMLElement>): void;
  38156. /**
  38157. * Gets the class name of the current intput.
  38158. * @returns the class name
  38159. */
  38160. getClassName(): string;
  38161. /**
  38162. * Get the friendly name associated with the input class.
  38163. * @returns the input friendly name
  38164. */
  38165. getSimpleName(): string;
  38166. }
  38167. }
  38168. declare module BABYLON {
  38169. /**
  38170. * This represents a FPS type of camera controlled by touch.
  38171. * This is like a universal camera minus the Gamepad controls.
  38172. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38173. */
  38174. export class TouchCamera extends FreeCamera {
  38175. /**
  38176. * Defines the touch sensibility for rotation.
  38177. * The higher the faster.
  38178. */
  38179. touchAngularSensibility: number;
  38180. /**
  38181. * Defines the touch sensibility for move.
  38182. * The higher the faster.
  38183. */
  38184. touchMoveSensibility: number;
  38185. /**
  38186. * Instantiates a new touch camera.
  38187. * This represents a FPS type of camera controlled by touch.
  38188. * This is like a universal camera minus the Gamepad controls.
  38189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38190. * @param name Define the name of the camera in the scene
  38191. * @param position Define the start position of the camera in the scene
  38192. * @param scene Define the scene the camera belongs to
  38193. */
  38194. constructor(name: string, position: Vector3, scene: Scene);
  38195. /**
  38196. * Gets the current object class name.
  38197. * @return the class name
  38198. */
  38199. getClassName(): string;
  38200. /** @hidden */
  38201. _setupInputs(): void;
  38202. }
  38203. }
  38204. declare module BABYLON {
  38205. /**
  38206. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38207. * being tilted forward or back and left or right.
  38208. */
  38209. export class DeviceOrientationCamera extends FreeCamera {
  38210. private _initialQuaternion;
  38211. private _quaternionCache;
  38212. private _tmpDragQuaternion;
  38213. /**
  38214. * Creates a new device orientation camera
  38215. * @param name The name of the camera
  38216. * @param position The start position camera
  38217. * @param scene The scene the camera belongs to
  38218. */
  38219. constructor(name: string, position: Vector3, scene: Scene);
  38220. /**
  38221. * @hidden
  38222. * Disabled pointer input on first orientation sensor update (Default: true)
  38223. */
  38224. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38225. private _dragFactor;
  38226. /**
  38227. * Enabled turning on the y axis when the orientation sensor is active
  38228. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38229. */
  38230. enableHorizontalDragging(dragFactor?: number): void;
  38231. /**
  38232. * Gets the current instance class name ("DeviceOrientationCamera").
  38233. * This helps avoiding instanceof at run time.
  38234. * @returns the class name
  38235. */
  38236. getClassName(): string;
  38237. /**
  38238. * @hidden
  38239. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38240. */
  38241. _checkInputs(): void;
  38242. /**
  38243. * Reset the camera to its default orientation on the specified axis only.
  38244. * @param axis The axis to reset
  38245. */
  38246. resetToCurrentRotation(axis?: Axis): void;
  38247. }
  38248. }
  38249. declare module BABYLON {
  38250. /**
  38251. * Defines supported buttons for XBox360 compatible gamepads
  38252. */
  38253. export enum Xbox360Button {
  38254. /** A */
  38255. A = 0,
  38256. /** B */
  38257. B = 1,
  38258. /** X */
  38259. X = 2,
  38260. /** Y */
  38261. Y = 3,
  38262. /** Start */
  38263. Start = 4,
  38264. /** Back */
  38265. Back = 5,
  38266. /** Left button */
  38267. LB = 6,
  38268. /** Right button */
  38269. RB = 7,
  38270. /** Left stick */
  38271. LeftStick = 8,
  38272. /** Right stick */
  38273. RightStick = 9
  38274. }
  38275. /** Defines values for XBox360 DPad */
  38276. export enum Xbox360Dpad {
  38277. /** Up */
  38278. Up = 0,
  38279. /** Down */
  38280. Down = 1,
  38281. /** Left */
  38282. Left = 2,
  38283. /** Right */
  38284. Right = 3
  38285. }
  38286. /**
  38287. * Defines a XBox360 gamepad
  38288. */
  38289. export class Xbox360Pad extends Gamepad {
  38290. private _leftTrigger;
  38291. private _rightTrigger;
  38292. private _onlefttriggerchanged;
  38293. private _onrighttriggerchanged;
  38294. private _onbuttondown;
  38295. private _onbuttonup;
  38296. private _ondpaddown;
  38297. private _ondpadup;
  38298. /** Observable raised when a button is pressed */
  38299. onButtonDownObservable: Observable<Xbox360Button>;
  38300. /** Observable raised when a button is released */
  38301. onButtonUpObservable: Observable<Xbox360Button>;
  38302. /** Observable raised when a pad is pressed */
  38303. onPadDownObservable: Observable<Xbox360Dpad>;
  38304. /** Observable raised when a pad is released */
  38305. onPadUpObservable: Observable<Xbox360Dpad>;
  38306. private _buttonA;
  38307. private _buttonB;
  38308. private _buttonX;
  38309. private _buttonY;
  38310. private _buttonBack;
  38311. private _buttonStart;
  38312. private _buttonLB;
  38313. private _buttonRB;
  38314. private _buttonLeftStick;
  38315. private _buttonRightStick;
  38316. private _dPadUp;
  38317. private _dPadDown;
  38318. private _dPadLeft;
  38319. private _dPadRight;
  38320. private _isXboxOnePad;
  38321. /**
  38322. * Creates a new XBox360 gamepad object
  38323. * @param id defines the id of this gamepad
  38324. * @param index defines its index
  38325. * @param gamepad defines the internal HTML gamepad object
  38326. * @param xboxOne defines if it is a XBox One gamepad
  38327. */
  38328. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38329. /**
  38330. * Defines the callback to call when left trigger is pressed
  38331. * @param callback defines the callback to use
  38332. */
  38333. onlefttriggerchanged(callback: (value: number) => void): void;
  38334. /**
  38335. * Defines the callback to call when right trigger is pressed
  38336. * @param callback defines the callback to use
  38337. */
  38338. onrighttriggerchanged(callback: (value: number) => void): void;
  38339. /**
  38340. * Gets the left trigger value
  38341. */
  38342. /**
  38343. * Sets the left trigger value
  38344. */
  38345. leftTrigger: number;
  38346. /**
  38347. * Gets the right trigger value
  38348. */
  38349. /**
  38350. * Sets the right trigger value
  38351. */
  38352. rightTrigger: number;
  38353. /**
  38354. * Defines the callback to call when a button is pressed
  38355. * @param callback defines the callback to use
  38356. */
  38357. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38358. /**
  38359. * Defines the callback to call when a button is released
  38360. * @param callback defines the callback to use
  38361. */
  38362. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38363. /**
  38364. * Defines the callback to call when a pad is pressed
  38365. * @param callback defines the callback to use
  38366. */
  38367. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38368. /**
  38369. * Defines the callback to call when a pad is released
  38370. * @param callback defines the callback to use
  38371. */
  38372. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38373. private _setButtonValue;
  38374. private _setDPadValue;
  38375. /**
  38376. * Gets the value of the `A` button
  38377. */
  38378. /**
  38379. * Sets the value of the `A` button
  38380. */
  38381. buttonA: number;
  38382. /**
  38383. * Gets the value of the `B` button
  38384. */
  38385. /**
  38386. * Sets the value of the `B` button
  38387. */
  38388. buttonB: number;
  38389. /**
  38390. * Gets the value of the `X` button
  38391. */
  38392. /**
  38393. * Sets the value of the `X` button
  38394. */
  38395. buttonX: number;
  38396. /**
  38397. * Gets the value of the `Y` button
  38398. */
  38399. /**
  38400. * Sets the value of the `Y` button
  38401. */
  38402. buttonY: number;
  38403. /**
  38404. * Gets the value of the `Start` button
  38405. */
  38406. /**
  38407. * Sets the value of the `Start` button
  38408. */
  38409. buttonStart: number;
  38410. /**
  38411. * Gets the value of the `Back` button
  38412. */
  38413. /**
  38414. * Sets the value of the `Back` button
  38415. */
  38416. buttonBack: number;
  38417. /**
  38418. * Gets the value of the `Left` button
  38419. */
  38420. /**
  38421. * Sets the value of the `Left` button
  38422. */
  38423. buttonLB: number;
  38424. /**
  38425. * Gets the value of the `Right` button
  38426. */
  38427. /**
  38428. * Sets the value of the `Right` button
  38429. */
  38430. buttonRB: number;
  38431. /**
  38432. * Gets the value of the Left joystick
  38433. */
  38434. /**
  38435. * Sets the value of the Left joystick
  38436. */
  38437. buttonLeftStick: number;
  38438. /**
  38439. * Gets the value of the Right joystick
  38440. */
  38441. /**
  38442. * Sets the value of the Right joystick
  38443. */
  38444. buttonRightStick: number;
  38445. /**
  38446. * Gets the value of D-pad up
  38447. */
  38448. /**
  38449. * Sets the value of D-pad up
  38450. */
  38451. dPadUp: number;
  38452. /**
  38453. * Gets the value of D-pad down
  38454. */
  38455. /**
  38456. * Sets the value of D-pad down
  38457. */
  38458. dPadDown: number;
  38459. /**
  38460. * Gets the value of D-pad left
  38461. */
  38462. /**
  38463. * Sets the value of D-pad left
  38464. */
  38465. dPadLeft: number;
  38466. /**
  38467. * Gets the value of D-pad right
  38468. */
  38469. /**
  38470. * Sets the value of D-pad right
  38471. */
  38472. dPadRight: number;
  38473. /**
  38474. * Force the gamepad to synchronize with device values
  38475. */
  38476. update(): void;
  38477. /**
  38478. * Disposes the gamepad
  38479. */
  38480. dispose(): void;
  38481. }
  38482. }
  38483. declare module BABYLON {
  38484. /**
  38485. * Manager for handling gamepads
  38486. */
  38487. export class GamepadManager {
  38488. private _scene?;
  38489. private _babylonGamepads;
  38490. private _oneGamepadConnected;
  38491. /** @hidden */
  38492. _isMonitoring: boolean;
  38493. private _gamepadEventSupported;
  38494. private _gamepadSupport;
  38495. /**
  38496. * observable to be triggered when the gamepad controller has been connected
  38497. */
  38498. onGamepadConnectedObservable: Observable<Gamepad>;
  38499. /**
  38500. * observable to be triggered when the gamepad controller has been disconnected
  38501. */
  38502. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38503. private _onGamepadConnectedEvent;
  38504. private _onGamepadDisconnectedEvent;
  38505. /**
  38506. * Initializes the gamepad manager
  38507. * @param _scene BabylonJS scene
  38508. */
  38509. constructor(_scene?: Scene | undefined);
  38510. /**
  38511. * The gamepads in the game pad manager
  38512. */
  38513. readonly gamepads: Gamepad[];
  38514. /**
  38515. * Get the gamepad controllers based on type
  38516. * @param type The type of gamepad controller
  38517. * @returns Nullable gamepad
  38518. */
  38519. getGamepadByType(type?: number): Nullable<Gamepad>;
  38520. /**
  38521. * Disposes the gamepad manager
  38522. */
  38523. dispose(): void;
  38524. private _addNewGamepad;
  38525. private _startMonitoringGamepads;
  38526. private _stopMonitoringGamepads;
  38527. /** @hidden */
  38528. _checkGamepadsStatus(): void;
  38529. private _updateGamepadObjects;
  38530. }
  38531. }
  38532. declare module BABYLON {
  38533. interface Scene {
  38534. /** @hidden */
  38535. _gamepadManager: Nullable<GamepadManager>;
  38536. /**
  38537. * Gets the gamepad manager associated with the scene
  38538. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38539. */
  38540. gamepadManager: GamepadManager;
  38541. }
  38542. /**
  38543. * Interface representing a free camera inputs manager
  38544. */
  38545. interface FreeCameraInputsManager {
  38546. /**
  38547. * Adds gamepad input support to the FreeCameraInputsManager.
  38548. * @returns the FreeCameraInputsManager
  38549. */
  38550. addGamepad(): FreeCameraInputsManager;
  38551. }
  38552. /**
  38553. * Interface representing an arc rotate camera inputs manager
  38554. */
  38555. interface ArcRotateCameraInputsManager {
  38556. /**
  38557. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38558. * @returns the camera inputs manager
  38559. */
  38560. addGamepad(): ArcRotateCameraInputsManager;
  38561. }
  38562. /**
  38563. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38564. */
  38565. export class GamepadSystemSceneComponent implements ISceneComponent {
  38566. /**
  38567. * The component name helpfull to identify the component in the list of scene components.
  38568. */
  38569. readonly name: string;
  38570. /**
  38571. * The scene the component belongs to.
  38572. */
  38573. scene: Scene;
  38574. /**
  38575. * Creates a new instance of the component for the given scene
  38576. * @param scene Defines the scene to register the component in
  38577. */
  38578. constructor(scene: Scene);
  38579. /**
  38580. * Registers the component in a given scene
  38581. */
  38582. register(): void;
  38583. /**
  38584. * Rebuilds the elements related to this component in case of
  38585. * context lost for instance.
  38586. */
  38587. rebuild(): void;
  38588. /**
  38589. * Disposes the component and the associated ressources
  38590. */
  38591. dispose(): void;
  38592. private _beforeCameraUpdate;
  38593. }
  38594. }
  38595. declare module BABYLON {
  38596. /**
  38597. * 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,
  38598. * which still works and will still be found in many Playgrounds.
  38599. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38600. */
  38601. export class UniversalCamera extends TouchCamera {
  38602. /**
  38603. * Defines the gamepad rotation sensiblity.
  38604. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38605. */
  38606. gamepadAngularSensibility: number;
  38607. /**
  38608. * Defines the gamepad move sensiblity.
  38609. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38610. */
  38611. gamepadMoveSensibility: number;
  38612. /**
  38613. * 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,
  38614. * which still works and will still be found in many Playgrounds.
  38615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38616. * @param name Define the name of the camera in the scene
  38617. * @param position Define the start position of the camera in the scene
  38618. * @param scene Define the scene the camera belongs to
  38619. */
  38620. constructor(name: string, position: Vector3, scene: Scene);
  38621. /**
  38622. * Gets the current object class name.
  38623. * @return the class name
  38624. */
  38625. getClassName(): string;
  38626. }
  38627. }
  38628. declare module BABYLON {
  38629. /**
  38630. * This represents a FPS type of camera. This is only here for back compat purpose.
  38631. * Please use the UniversalCamera instead as both are identical.
  38632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38633. */
  38634. export class GamepadCamera extends UniversalCamera {
  38635. /**
  38636. * Instantiates a new Gamepad Camera
  38637. * This represents a FPS type of camera. This is only here for back compat purpose.
  38638. * Please use the UniversalCamera instead as both are identical.
  38639. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38640. * @param name Define the name of the camera in the scene
  38641. * @param position Define the start position of the camera in the scene
  38642. * @param scene Define the scene the camera belongs to
  38643. */
  38644. constructor(name: string, position: Vector3, scene: Scene);
  38645. /**
  38646. * Gets the current object class name.
  38647. * @return the class name
  38648. */
  38649. getClassName(): string;
  38650. }
  38651. }
  38652. declare module BABYLON {
  38653. /** @hidden */
  38654. export var passPixelShader: {
  38655. name: string;
  38656. shader: string;
  38657. };
  38658. }
  38659. declare module BABYLON {
  38660. /** @hidden */
  38661. export var passCubePixelShader: {
  38662. name: string;
  38663. shader: string;
  38664. };
  38665. }
  38666. declare module BABYLON {
  38667. /**
  38668. * PassPostProcess which produces an output the same as it's input
  38669. */
  38670. export class PassPostProcess extends PostProcess {
  38671. /**
  38672. * Creates the PassPostProcess
  38673. * @param name The name of the effect.
  38674. * @param options The required width/height ratio to downsize to before computing the render pass.
  38675. * @param camera The camera to apply the render pass to.
  38676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38677. * @param engine The engine which the post process will be applied. (default: current engine)
  38678. * @param reusable If the post process can be reused on the same frame. (default: false)
  38679. * @param textureType The type of texture to be used when performing the post processing.
  38680. * @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)
  38681. */
  38682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38683. }
  38684. /**
  38685. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38686. */
  38687. export class PassCubePostProcess extends PostProcess {
  38688. private _face;
  38689. /**
  38690. * Gets or sets the cube face to display.
  38691. * * 0 is +X
  38692. * * 1 is -X
  38693. * * 2 is +Y
  38694. * * 3 is -Y
  38695. * * 4 is +Z
  38696. * * 5 is -Z
  38697. */
  38698. face: number;
  38699. /**
  38700. * Creates the PassCubePostProcess
  38701. * @param name The name of the effect.
  38702. * @param options The required width/height ratio to downsize to before computing the render pass.
  38703. * @param camera The camera to apply the render pass to.
  38704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38705. * @param engine The engine which the post process will be applied. (default: current engine)
  38706. * @param reusable If the post process can be reused on the same frame. (default: false)
  38707. * @param textureType The type of texture to be used when performing the post processing.
  38708. * @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)
  38709. */
  38710. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38711. }
  38712. }
  38713. declare module BABYLON {
  38714. /** @hidden */
  38715. export var anaglyphPixelShader: {
  38716. name: string;
  38717. shader: string;
  38718. };
  38719. }
  38720. declare module BABYLON {
  38721. /**
  38722. * Postprocess used to generate anaglyphic rendering
  38723. */
  38724. export class AnaglyphPostProcess extends PostProcess {
  38725. private _passedProcess;
  38726. /**
  38727. * Creates a new AnaglyphPostProcess
  38728. * @param name defines postprocess name
  38729. * @param options defines creation options or target ratio scale
  38730. * @param rigCameras defines cameras using this postprocess
  38731. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38732. * @param engine defines hosting engine
  38733. * @param reusable defines if the postprocess will be reused multiple times per frame
  38734. */
  38735. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38736. }
  38737. }
  38738. declare module BABYLON {
  38739. /**
  38740. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38741. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38742. */
  38743. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38744. /**
  38745. * Creates a new AnaglyphArcRotateCamera
  38746. * @param name defines camera name
  38747. * @param alpha defines alpha angle (in radians)
  38748. * @param beta defines beta angle (in radians)
  38749. * @param radius defines radius
  38750. * @param target defines camera target
  38751. * @param interaxialDistance defines distance between each color axis
  38752. * @param scene defines the hosting scene
  38753. */
  38754. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38755. /**
  38756. * Gets camera class name
  38757. * @returns AnaglyphArcRotateCamera
  38758. */
  38759. getClassName(): string;
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /**
  38764. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38765. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38766. */
  38767. export class AnaglyphFreeCamera extends FreeCamera {
  38768. /**
  38769. * Creates a new AnaglyphFreeCamera
  38770. * @param name defines camera name
  38771. * @param position defines initial position
  38772. * @param interaxialDistance defines distance between each color axis
  38773. * @param scene defines the hosting scene
  38774. */
  38775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38776. /**
  38777. * Gets camera class name
  38778. * @returns AnaglyphFreeCamera
  38779. */
  38780. getClassName(): string;
  38781. }
  38782. }
  38783. declare module BABYLON {
  38784. /**
  38785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38787. */
  38788. export class AnaglyphGamepadCamera extends GamepadCamera {
  38789. /**
  38790. * Creates a new AnaglyphGamepadCamera
  38791. * @param name defines camera name
  38792. * @param position defines initial position
  38793. * @param interaxialDistance defines distance between each color axis
  38794. * @param scene defines the hosting scene
  38795. */
  38796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38797. /**
  38798. * Gets camera class name
  38799. * @returns AnaglyphGamepadCamera
  38800. */
  38801. getClassName(): string;
  38802. }
  38803. }
  38804. declare module BABYLON {
  38805. /**
  38806. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38807. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38808. */
  38809. export class AnaglyphUniversalCamera extends UniversalCamera {
  38810. /**
  38811. * Creates a new AnaglyphUniversalCamera
  38812. * @param name defines camera name
  38813. * @param position defines initial position
  38814. * @param interaxialDistance defines distance between each color axis
  38815. * @param scene defines the hosting scene
  38816. */
  38817. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38818. /**
  38819. * Gets camera class name
  38820. * @returns AnaglyphUniversalCamera
  38821. */
  38822. getClassName(): string;
  38823. }
  38824. }
  38825. declare module BABYLON {
  38826. /** @hidden */
  38827. export var stereoscopicInterlacePixelShader: {
  38828. name: string;
  38829. shader: string;
  38830. };
  38831. }
  38832. declare module BABYLON {
  38833. /**
  38834. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38835. */
  38836. export class StereoscopicInterlacePostProcess extends PostProcess {
  38837. private _stepSize;
  38838. private _passedProcess;
  38839. /**
  38840. * Initializes a StereoscopicInterlacePostProcess
  38841. * @param name The name of the effect.
  38842. * @param rigCameras The rig cameras to be appled to the post process
  38843. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38845. * @param engine The engine which the post process will be applied. (default: current engine)
  38846. * @param reusable If the post process can be reused on the same frame. (default: false)
  38847. */
  38848. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38849. }
  38850. }
  38851. declare module BABYLON {
  38852. /**
  38853. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38854. * @see http://doc.babylonjs.com/features/cameras
  38855. */
  38856. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38857. /**
  38858. * Creates a new StereoscopicArcRotateCamera
  38859. * @param name defines camera name
  38860. * @param alpha defines alpha angle (in radians)
  38861. * @param beta defines beta angle (in radians)
  38862. * @param radius defines radius
  38863. * @param target defines camera target
  38864. * @param interaxialDistance defines distance between each color axis
  38865. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38866. * @param scene defines the hosting scene
  38867. */
  38868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38869. /**
  38870. * Gets camera class name
  38871. * @returns StereoscopicArcRotateCamera
  38872. */
  38873. getClassName(): string;
  38874. }
  38875. }
  38876. declare module BABYLON {
  38877. /**
  38878. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38879. * @see http://doc.babylonjs.com/features/cameras
  38880. */
  38881. export class StereoscopicFreeCamera extends FreeCamera {
  38882. /**
  38883. * Creates a new StereoscopicFreeCamera
  38884. * @param name defines camera name
  38885. * @param position defines initial position
  38886. * @param interaxialDistance defines distance between each color axis
  38887. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38888. * @param scene defines the hosting scene
  38889. */
  38890. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38891. /**
  38892. * Gets camera class name
  38893. * @returns StereoscopicFreeCamera
  38894. */
  38895. getClassName(): string;
  38896. }
  38897. }
  38898. declare module BABYLON {
  38899. /**
  38900. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38901. * @see http://doc.babylonjs.com/features/cameras
  38902. */
  38903. export class StereoscopicGamepadCamera extends GamepadCamera {
  38904. /**
  38905. * Creates a new StereoscopicGamepadCamera
  38906. * @param name defines camera name
  38907. * @param position defines initial position
  38908. * @param interaxialDistance defines distance between each color axis
  38909. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38910. * @param scene defines the hosting scene
  38911. */
  38912. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38913. /**
  38914. * Gets camera class name
  38915. * @returns StereoscopicGamepadCamera
  38916. */
  38917. getClassName(): string;
  38918. }
  38919. }
  38920. declare module BABYLON {
  38921. /**
  38922. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38923. * @see http://doc.babylonjs.com/features/cameras
  38924. */
  38925. export class StereoscopicUniversalCamera extends UniversalCamera {
  38926. /**
  38927. * Creates a new StereoscopicUniversalCamera
  38928. * @param name defines camera name
  38929. * @param position defines initial position
  38930. * @param interaxialDistance defines distance between each color axis
  38931. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38932. * @param scene defines the hosting scene
  38933. */
  38934. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38935. /**
  38936. * Gets camera class name
  38937. * @returns StereoscopicUniversalCamera
  38938. */
  38939. getClassName(): string;
  38940. }
  38941. }
  38942. declare module BABYLON {
  38943. /**
  38944. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38945. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38946. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38947. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38948. */
  38949. export class VirtualJoysticksCamera extends FreeCamera {
  38950. /**
  38951. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38952. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38953. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38954. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38955. * @param name Define the name of the camera in the scene
  38956. * @param position Define the start position of the camera in the scene
  38957. * @param scene Define the scene the camera belongs to
  38958. */
  38959. constructor(name: string, position: Vector3, scene: Scene);
  38960. /**
  38961. * Gets the current object class name.
  38962. * @return the class name
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module BABYLON {
  38968. /**
  38969. * This represents all the required metrics to create a VR camera.
  38970. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38971. */
  38972. export class VRCameraMetrics {
  38973. /**
  38974. * Define the horizontal resolution off the screen.
  38975. */
  38976. hResolution: number;
  38977. /**
  38978. * Define the vertical resolution off the screen.
  38979. */
  38980. vResolution: number;
  38981. /**
  38982. * Define the horizontal screen size.
  38983. */
  38984. hScreenSize: number;
  38985. /**
  38986. * Define the vertical screen size.
  38987. */
  38988. vScreenSize: number;
  38989. /**
  38990. * Define the vertical screen center position.
  38991. */
  38992. vScreenCenter: number;
  38993. /**
  38994. * Define the distance of the eyes to the screen.
  38995. */
  38996. eyeToScreenDistance: number;
  38997. /**
  38998. * Define the distance between both lenses
  38999. */
  39000. lensSeparationDistance: number;
  39001. /**
  39002. * Define the distance between both viewer's eyes.
  39003. */
  39004. interpupillaryDistance: number;
  39005. /**
  39006. * Define the distortion factor of the VR postprocess.
  39007. * Please, touch with care.
  39008. */
  39009. distortionK: number[];
  39010. /**
  39011. * Define the chromatic aberration correction factors for the VR post process.
  39012. */
  39013. chromaAbCorrection: number[];
  39014. /**
  39015. * Define the scale factor of the post process.
  39016. * The smaller the better but the slower.
  39017. */
  39018. postProcessScaleFactor: number;
  39019. /**
  39020. * Define an offset for the lens center.
  39021. */
  39022. lensCenterOffset: number;
  39023. /**
  39024. * Define if the current vr camera should compensate the distortion of the lense or not.
  39025. */
  39026. compensateDistortion: boolean;
  39027. /**
  39028. * Defines if multiview should be enabled when rendering (Default: false)
  39029. */
  39030. multiviewEnabled: boolean;
  39031. /**
  39032. * Gets the rendering aspect ratio based on the provided resolutions.
  39033. */
  39034. readonly aspectRatio: number;
  39035. /**
  39036. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39037. */
  39038. readonly aspectRatioFov: number;
  39039. /**
  39040. * @hidden
  39041. */
  39042. readonly leftHMatrix: Matrix;
  39043. /**
  39044. * @hidden
  39045. */
  39046. readonly rightHMatrix: Matrix;
  39047. /**
  39048. * @hidden
  39049. */
  39050. readonly leftPreViewMatrix: Matrix;
  39051. /**
  39052. * @hidden
  39053. */
  39054. readonly rightPreViewMatrix: Matrix;
  39055. /**
  39056. * Get the default VRMetrics based on the most generic setup.
  39057. * @returns the default vr metrics
  39058. */
  39059. static GetDefault(): VRCameraMetrics;
  39060. }
  39061. }
  39062. declare module BABYLON {
  39063. /** @hidden */
  39064. export var vrDistortionCorrectionPixelShader: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module BABYLON {
  39070. /**
  39071. * VRDistortionCorrectionPostProcess used for mobile VR
  39072. */
  39073. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39074. private _isRightEye;
  39075. private _distortionFactors;
  39076. private _postProcessScaleFactor;
  39077. private _lensCenterOffset;
  39078. private _scaleIn;
  39079. private _scaleFactor;
  39080. private _lensCenter;
  39081. /**
  39082. * Initializes the VRDistortionCorrectionPostProcess
  39083. * @param name The name of the effect.
  39084. * @param camera The camera to apply the render pass to.
  39085. * @param isRightEye If this is for the right eye distortion
  39086. * @param vrMetrics All the required metrics for the VR camera
  39087. */
  39088. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39089. }
  39090. }
  39091. declare module BABYLON {
  39092. /**
  39093. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39094. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39095. */
  39096. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39097. /**
  39098. * Creates a new VRDeviceOrientationArcRotateCamera
  39099. * @param name defines camera name
  39100. * @param alpha defines the camera rotation along the logitudinal axis
  39101. * @param beta defines the camera rotation along the latitudinal axis
  39102. * @param radius defines the camera distance from its target
  39103. * @param target defines the camera target
  39104. * @param scene defines the scene the camera belongs to
  39105. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39106. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39107. */
  39108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39109. /**
  39110. * Gets camera class name
  39111. * @returns VRDeviceOrientationArcRotateCamera
  39112. */
  39113. getClassName(): string;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * Camera used to simulate VR rendering (based on FreeCamera)
  39119. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39120. */
  39121. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39122. /**
  39123. * Creates a new VRDeviceOrientationFreeCamera
  39124. * @param name defines camera name
  39125. * @param position defines the start position of the camera
  39126. * @param scene defines the scene the camera belongs to
  39127. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39128. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39129. */
  39130. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39131. /**
  39132. * Gets camera class name
  39133. * @returns VRDeviceOrientationFreeCamera
  39134. */
  39135. getClassName(): string;
  39136. }
  39137. }
  39138. declare module BABYLON {
  39139. /**
  39140. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39141. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39142. */
  39143. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39144. /**
  39145. * Creates a new VRDeviceOrientationGamepadCamera
  39146. * @param name defines camera name
  39147. * @param position defines the start position of the camera
  39148. * @param scene defines the scene the camera belongs to
  39149. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39150. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39151. */
  39152. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39153. /**
  39154. * Gets camera class name
  39155. * @returns VRDeviceOrientationGamepadCamera
  39156. */
  39157. getClassName(): string;
  39158. }
  39159. }
  39160. declare module BABYLON {
  39161. /**
  39162. * Base class of materials working in push mode in babylon JS
  39163. * @hidden
  39164. */
  39165. export class PushMaterial extends Material {
  39166. protected _activeEffect: Effect;
  39167. protected _normalMatrix: Matrix;
  39168. /**
  39169. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39170. * This means that the material can keep using a previous shader while a new one is being compiled.
  39171. * This is mostly used when shader parallel compilation is supported (true by default)
  39172. */
  39173. allowShaderHotSwapping: boolean;
  39174. constructor(name: string, scene: Scene);
  39175. getEffect(): Effect;
  39176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39177. /**
  39178. * Binds the given world matrix to the active effect
  39179. *
  39180. * @param world the matrix to bind
  39181. */
  39182. bindOnlyWorldMatrix(world: Matrix): void;
  39183. /**
  39184. * Binds the given normal matrix to the active effect
  39185. *
  39186. * @param normalMatrix the matrix to bind
  39187. */
  39188. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39189. bind(world: Matrix, mesh?: Mesh): void;
  39190. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39191. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39192. }
  39193. }
  39194. declare module BABYLON {
  39195. /**
  39196. * This groups all the flags used to control the materials channel.
  39197. */
  39198. export class MaterialFlags {
  39199. private static _DiffuseTextureEnabled;
  39200. /**
  39201. * Are diffuse textures enabled in the application.
  39202. */
  39203. static DiffuseTextureEnabled: boolean;
  39204. private static _AmbientTextureEnabled;
  39205. /**
  39206. * Are ambient textures enabled in the application.
  39207. */
  39208. static AmbientTextureEnabled: boolean;
  39209. private static _OpacityTextureEnabled;
  39210. /**
  39211. * Are opacity textures enabled in the application.
  39212. */
  39213. static OpacityTextureEnabled: boolean;
  39214. private static _ReflectionTextureEnabled;
  39215. /**
  39216. * Are reflection textures enabled in the application.
  39217. */
  39218. static ReflectionTextureEnabled: boolean;
  39219. private static _EmissiveTextureEnabled;
  39220. /**
  39221. * Are emissive textures enabled in the application.
  39222. */
  39223. static EmissiveTextureEnabled: boolean;
  39224. private static _SpecularTextureEnabled;
  39225. /**
  39226. * Are specular textures enabled in the application.
  39227. */
  39228. static SpecularTextureEnabled: boolean;
  39229. private static _BumpTextureEnabled;
  39230. /**
  39231. * Are bump textures enabled in the application.
  39232. */
  39233. static BumpTextureEnabled: boolean;
  39234. private static _LightmapTextureEnabled;
  39235. /**
  39236. * Are lightmap textures enabled in the application.
  39237. */
  39238. static LightmapTextureEnabled: boolean;
  39239. private static _RefractionTextureEnabled;
  39240. /**
  39241. * Are refraction textures enabled in the application.
  39242. */
  39243. static RefractionTextureEnabled: boolean;
  39244. private static _ColorGradingTextureEnabled;
  39245. /**
  39246. * Are color grading textures enabled in the application.
  39247. */
  39248. static ColorGradingTextureEnabled: boolean;
  39249. private static _FresnelEnabled;
  39250. /**
  39251. * Are fresnels enabled in the application.
  39252. */
  39253. static FresnelEnabled: boolean;
  39254. private static _ClearCoatTextureEnabled;
  39255. /**
  39256. * Are clear coat textures enabled in the application.
  39257. */
  39258. static ClearCoatTextureEnabled: boolean;
  39259. private static _ClearCoatBumpTextureEnabled;
  39260. /**
  39261. * Are clear coat bump textures enabled in the application.
  39262. */
  39263. static ClearCoatBumpTextureEnabled: boolean;
  39264. private static _ClearCoatTintTextureEnabled;
  39265. /**
  39266. * Are clear coat tint textures enabled in the application.
  39267. */
  39268. static ClearCoatTintTextureEnabled: boolean;
  39269. private static _SheenTextureEnabled;
  39270. /**
  39271. * Are sheen textures enabled in the application.
  39272. */
  39273. static SheenTextureEnabled: boolean;
  39274. private static _AnisotropicTextureEnabled;
  39275. /**
  39276. * Are anisotropic textures enabled in the application.
  39277. */
  39278. static AnisotropicTextureEnabled: boolean;
  39279. private static _ThicknessTextureEnabled;
  39280. /**
  39281. * Are thickness textures enabled in the application.
  39282. */
  39283. static ThicknessTextureEnabled: boolean;
  39284. }
  39285. }
  39286. declare module BABYLON {
  39287. /** @hidden */
  39288. export var defaultFragmentDeclaration: {
  39289. name: string;
  39290. shader: string;
  39291. };
  39292. }
  39293. declare module BABYLON {
  39294. /** @hidden */
  39295. export var defaultUboDeclaration: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module BABYLON {
  39301. /** @hidden */
  39302. export var lightFragmentDeclaration: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module BABYLON {
  39308. /** @hidden */
  39309. export var lightUboDeclaration: {
  39310. name: string;
  39311. shader: string;
  39312. };
  39313. }
  39314. declare module BABYLON {
  39315. /** @hidden */
  39316. export var lightsFragmentFunctions: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module BABYLON {
  39322. /** @hidden */
  39323. export var shadowsFragmentFunctions: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module BABYLON {
  39329. /** @hidden */
  39330. export var fresnelFunction: {
  39331. name: string;
  39332. shader: string;
  39333. };
  39334. }
  39335. declare module BABYLON {
  39336. /** @hidden */
  39337. export var reflectionFunction: {
  39338. name: string;
  39339. shader: string;
  39340. };
  39341. }
  39342. declare module BABYLON {
  39343. /** @hidden */
  39344. export var bumpFragmentFunctions: {
  39345. name: string;
  39346. shader: string;
  39347. };
  39348. }
  39349. declare module BABYLON {
  39350. /** @hidden */
  39351. export var logDepthDeclaration: {
  39352. name: string;
  39353. shader: string;
  39354. };
  39355. }
  39356. declare module BABYLON {
  39357. /** @hidden */
  39358. export var bumpFragment: {
  39359. name: string;
  39360. shader: string;
  39361. };
  39362. }
  39363. declare module BABYLON {
  39364. /** @hidden */
  39365. export var depthPrePass: {
  39366. name: string;
  39367. shader: string;
  39368. };
  39369. }
  39370. declare module BABYLON {
  39371. /** @hidden */
  39372. export var lightFragment: {
  39373. name: string;
  39374. shader: string;
  39375. };
  39376. }
  39377. declare module BABYLON {
  39378. /** @hidden */
  39379. export var logDepthFragment: {
  39380. name: string;
  39381. shader: string;
  39382. };
  39383. }
  39384. declare module BABYLON {
  39385. /** @hidden */
  39386. export var defaultPixelShader: {
  39387. name: string;
  39388. shader: string;
  39389. };
  39390. }
  39391. declare module BABYLON {
  39392. /** @hidden */
  39393. export var defaultVertexDeclaration: {
  39394. name: string;
  39395. shader: string;
  39396. };
  39397. }
  39398. declare module BABYLON {
  39399. /** @hidden */
  39400. export var bumpVertexDeclaration: {
  39401. name: string;
  39402. shader: string;
  39403. };
  39404. }
  39405. declare module BABYLON {
  39406. /** @hidden */
  39407. export var bumpVertex: {
  39408. name: string;
  39409. shader: string;
  39410. };
  39411. }
  39412. declare module BABYLON {
  39413. /** @hidden */
  39414. export var fogVertex: {
  39415. name: string;
  39416. shader: string;
  39417. };
  39418. }
  39419. declare module BABYLON {
  39420. /** @hidden */
  39421. export var shadowsVertex: {
  39422. name: string;
  39423. shader: string;
  39424. };
  39425. }
  39426. declare module BABYLON {
  39427. /** @hidden */
  39428. export var pointCloudVertex: {
  39429. name: string;
  39430. shader: string;
  39431. };
  39432. }
  39433. declare module BABYLON {
  39434. /** @hidden */
  39435. export var logDepthVertex: {
  39436. name: string;
  39437. shader: string;
  39438. };
  39439. }
  39440. declare module BABYLON {
  39441. /** @hidden */
  39442. export var defaultVertexShader: {
  39443. name: string;
  39444. shader: string;
  39445. };
  39446. }
  39447. declare module BABYLON {
  39448. /** @hidden */
  39449. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39450. MAINUV1: boolean;
  39451. MAINUV2: boolean;
  39452. DIFFUSE: boolean;
  39453. DIFFUSEDIRECTUV: number;
  39454. AMBIENT: boolean;
  39455. AMBIENTDIRECTUV: number;
  39456. OPACITY: boolean;
  39457. OPACITYDIRECTUV: number;
  39458. OPACITYRGB: boolean;
  39459. REFLECTION: boolean;
  39460. EMISSIVE: boolean;
  39461. EMISSIVEDIRECTUV: number;
  39462. SPECULAR: boolean;
  39463. SPECULARDIRECTUV: number;
  39464. BUMP: boolean;
  39465. BUMPDIRECTUV: number;
  39466. PARALLAX: boolean;
  39467. PARALLAXOCCLUSION: boolean;
  39468. SPECULAROVERALPHA: boolean;
  39469. CLIPPLANE: boolean;
  39470. CLIPPLANE2: boolean;
  39471. CLIPPLANE3: boolean;
  39472. CLIPPLANE4: boolean;
  39473. ALPHATEST: boolean;
  39474. DEPTHPREPASS: boolean;
  39475. ALPHAFROMDIFFUSE: boolean;
  39476. POINTSIZE: boolean;
  39477. FOG: boolean;
  39478. SPECULARTERM: boolean;
  39479. DIFFUSEFRESNEL: boolean;
  39480. OPACITYFRESNEL: boolean;
  39481. REFLECTIONFRESNEL: boolean;
  39482. REFRACTIONFRESNEL: boolean;
  39483. EMISSIVEFRESNEL: boolean;
  39484. FRESNEL: boolean;
  39485. NORMAL: boolean;
  39486. UV1: boolean;
  39487. UV2: boolean;
  39488. VERTEXCOLOR: boolean;
  39489. VERTEXALPHA: boolean;
  39490. NUM_BONE_INFLUENCERS: number;
  39491. BonesPerMesh: number;
  39492. BONETEXTURE: boolean;
  39493. INSTANCES: boolean;
  39494. GLOSSINESS: boolean;
  39495. ROUGHNESS: boolean;
  39496. EMISSIVEASILLUMINATION: boolean;
  39497. LINKEMISSIVEWITHDIFFUSE: boolean;
  39498. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39499. LIGHTMAP: boolean;
  39500. LIGHTMAPDIRECTUV: number;
  39501. OBJECTSPACE_NORMALMAP: boolean;
  39502. USELIGHTMAPASSHADOWMAP: boolean;
  39503. REFLECTIONMAP_3D: boolean;
  39504. REFLECTIONMAP_SPHERICAL: boolean;
  39505. REFLECTIONMAP_PLANAR: boolean;
  39506. REFLECTIONMAP_CUBIC: boolean;
  39507. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39508. REFLECTIONMAP_PROJECTION: boolean;
  39509. REFLECTIONMAP_SKYBOX: boolean;
  39510. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39511. REFLECTIONMAP_EXPLICIT: boolean;
  39512. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39513. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39514. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39515. INVERTCUBICMAP: boolean;
  39516. LOGARITHMICDEPTH: boolean;
  39517. REFRACTION: boolean;
  39518. REFRACTIONMAP_3D: boolean;
  39519. REFLECTIONOVERALPHA: boolean;
  39520. TWOSIDEDLIGHTING: boolean;
  39521. SHADOWFLOAT: boolean;
  39522. MORPHTARGETS: boolean;
  39523. MORPHTARGETS_NORMAL: boolean;
  39524. MORPHTARGETS_TANGENT: boolean;
  39525. MORPHTARGETS_UV: boolean;
  39526. NUM_MORPH_INFLUENCERS: number;
  39527. NONUNIFORMSCALING: boolean;
  39528. PREMULTIPLYALPHA: boolean;
  39529. IMAGEPROCESSING: boolean;
  39530. VIGNETTE: boolean;
  39531. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39532. VIGNETTEBLENDMODEOPAQUE: boolean;
  39533. TONEMAPPING: boolean;
  39534. TONEMAPPING_ACES: boolean;
  39535. CONTRAST: boolean;
  39536. COLORCURVES: boolean;
  39537. COLORGRADING: boolean;
  39538. COLORGRADING3D: boolean;
  39539. SAMPLER3DGREENDEPTH: boolean;
  39540. SAMPLER3DBGRMAP: boolean;
  39541. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39542. MULTIVIEW: boolean;
  39543. /**
  39544. * If the reflection texture on this material is in linear color space
  39545. * @hidden
  39546. */
  39547. IS_REFLECTION_LINEAR: boolean;
  39548. /**
  39549. * If the refraction texture on this material is in linear color space
  39550. * @hidden
  39551. */
  39552. IS_REFRACTION_LINEAR: boolean;
  39553. EXPOSURE: boolean;
  39554. constructor();
  39555. setReflectionMode(modeToEnable: string): void;
  39556. }
  39557. /**
  39558. * This is the default material used in Babylon. It is the best trade off between quality
  39559. * and performances.
  39560. * @see http://doc.babylonjs.com/babylon101/materials
  39561. */
  39562. export class StandardMaterial extends PushMaterial {
  39563. private _diffuseTexture;
  39564. /**
  39565. * The basic texture of the material as viewed under a light.
  39566. */
  39567. diffuseTexture: Nullable<BaseTexture>;
  39568. private _ambientTexture;
  39569. /**
  39570. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39571. */
  39572. ambientTexture: Nullable<BaseTexture>;
  39573. private _opacityTexture;
  39574. /**
  39575. * Define the transparency of the material from a texture.
  39576. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39577. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39578. */
  39579. opacityTexture: Nullable<BaseTexture>;
  39580. private _reflectionTexture;
  39581. /**
  39582. * Define the texture used to display the reflection.
  39583. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39584. */
  39585. reflectionTexture: Nullable<BaseTexture>;
  39586. private _emissiveTexture;
  39587. /**
  39588. * Define texture of the material as if self lit.
  39589. * This will be mixed in the final result even in the absence of light.
  39590. */
  39591. emissiveTexture: Nullable<BaseTexture>;
  39592. private _specularTexture;
  39593. /**
  39594. * Define how the color and intensity of the highlight given by the light in the material.
  39595. */
  39596. specularTexture: Nullable<BaseTexture>;
  39597. private _bumpTexture;
  39598. /**
  39599. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39600. * 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.
  39601. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39602. */
  39603. bumpTexture: Nullable<BaseTexture>;
  39604. private _lightmapTexture;
  39605. /**
  39606. * Complex lighting can be computationally expensive to compute at runtime.
  39607. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39608. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39609. */
  39610. lightmapTexture: Nullable<BaseTexture>;
  39611. private _refractionTexture;
  39612. /**
  39613. * Define the texture used to display the refraction.
  39614. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39615. */
  39616. refractionTexture: Nullable<BaseTexture>;
  39617. /**
  39618. * The color of the material lit by the environmental background lighting.
  39619. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39620. */
  39621. ambientColor: Color3;
  39622. /**
  39623. * The basic color of the material as viewed under a light.
  39624. */
  39625. diffuseColor: Color3;
  39626. /**
  39627. * Define how the color and intensity of the highlight given by the light in the material.
  39628. */
  39629. specularColor: Color3;
  39630. /**
  39631. * Define the color of the material as if self lit.
  39632. * This will be mixed in the final result even in the absence of light.
  39633. */
  39634. emissiveColor: Color3;
  39635. /**
  39636. * Defines how sharp are the highlights in the material.
  39637. * The bigger the value the sharper giving a more glossy feeling to the result.
  39638. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39639. */
  39640. specularPower: number;
  39641. private _useAlphaFromDiffuseTexture;
  39642. /**
  39643. * Does the transparency come from the diffuse texture alpha channel.
  39644. */
  39645. useAlphaFromDiffuseTexture: boolean;
  39646. private _useEmissiveAsIllumination;
  39647. /**
  39648. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39649. */
  39650. useEmissiveAsIllumination: boolean;
  39651. private _linkEmissiveWithDiffuse;
  39652. /**
  39653. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39654. * the emissive level when the final color is close to one.
  39655. */
  39656. linkEmissiveWithDiffuse: boolean;
  39657. private _useSpecularOverAlpha;
  39658. /**
  39659. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39661. */
  39662. useSpecularOverAlpha: boolean;
  39663. private _useReflectionOverAlpha;
  39664. /**
  39665. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39666. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39667. */
  39668. useReflectionOverAlpha: boolean;
  39669. private _disableLighting;
  39670. /**
  39671. * Does lights from the scene impacts this material.
  39672. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39673. */
  39674. disableLighting: boolean;
  39675. private _useObjectSpaceNormalMap;
  39676. /**
  39677. * Allows using an object space normal map (instead of tangent space).
  39678. */
  39679. useObjectSpaceNormalMap: boolean;
  39680. private _useParallax;
  39681. /**
  39682. * Is parallax enabled or not.
  39683. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39684. */
  39685. useParallax: boolean;
  39686. private _useParallaxOcclusion;
  39687. /**
  39688. * Is parallax occlusion enabled or not.
  39689. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39690. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39691. */
  39692. useParallaxOcclusion: boolean;
  39693. /**
  39694. * 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.
  39695. */
  39696. parallaxScaleBias: number;
  39697. private _roughness;
  39698. /**
  39699. * Helps to define how blurry the reflections should appears in the material.
  39700. */
  39701. roughness: number;
  39702. /**
  39703. * In case of refraction, define the value of the index of refraction.
  39704. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39705. */
  39706. indexOfRefraction: number;
  39707. /**
  39708. * Invert the refraction texture alongside the y axis.
  39709. * It can be useful with procedural textures or probe for instance.
  39710. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39711. */
  39712. invertRefractionY: boolean;
  39713. /**
  39714. * Defines the alpha limits in alpha test mode.
  39715. */
  39716. alphaCutOff: number;
  39717. private _useLightmapAsShadowmap;
  39718. /**
  39719. * In case of light mapping, define whether the map contains light or shadow informations.
  39720. */
  39721. useLightmapAsShadowmap: boolean;
  39722. private _diffuseFresnelParameters;
  39723. /**
  39724. * Define the diffuse fresnel parameters of the material.
  39725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39726. */
  39727. diffuseFresnelParameters: FresnelParameters;
  39728. private _opacityFresnelParameters;
  39729. /**
  39730. * Define the opacity fresnel parameters of the material.
  39731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39732. */
  39733. opacityFresnelParameters: FresnelParameters;
  39734. private _reflectionFresnelParameters;
  39735. /**
  39736. * Define the reflection fresnel parameters of the material.
  39737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39738. */
  39739. reflectionFresnelParameters: FresnelParameters;
  39740. private _refractionFresnelParameters;
  39741. /**
  39742. * Define the refraction fresnel parameters of the material.
  39743. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39744. */
  39745. refractionFresnelParameters: FresnelParameters;
  39746. private _emissiveFresnelParameters;
  39747. /**
  39748. * Define the emissive fresnel parameters of the material.
  39749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39750. */
  39751. emissiveFresnelParameters: FresnelParameters;
  39752. private _useReflectionFresnelFromSpecular;
  39753. /**
  39754. * If true automatically deducts the fresnels values from the material specularity.
  39755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39756. */
  39757. useReflectionFresnelFromSpecular: boolean;
  39758. private _useGlossinessFromSpecularMapAlpha;
  39759. /**
  39760. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39761. */
  39762. useGlossinessFromSpecularMapAlpha: boolean;
  39763. private _maxSimultaneousLights;
  39764. /**
  39765. * Defines the maximum number of lights that can be used in the material
  39766. */
  39767. maxSimultaneousLights: number;
  39768. private _invertNormalMapX;
  39769. /**
  39770. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39771. */
  39772. invertNormalMapX: boolean;
  39773. private _invertNormalMapY;
  39774. /**
  39775. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39776. */
  39777. invertNormalMapY: boolean;
  39778. private _twoSidedLighting;
  39779. /**
  39780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39781. */
  39782. twoSidedLighting: boolean;
  39783. /**
  39784. * Default configuration related to image processing available in the standard Material.
  39785. */
  39786. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39787. /**
  39788. * Gets the image processing configuration used either in this material.
  39789. */
  39790. /**
  39791. * Sets the Default image processing configuration used either in the this material.
  39792. *
  39793. * If sets to null, the scene one is in use.
  39794. */
  39795. imageProcessingConfiguration: ImageProcessingConfiguration;
  39796. /**
  39797. * Keep track of the image processing observer to allow dispose and replace.
  39798. */
  39799. private _imageProcessingObserver;
  39800. /**
  39801. * Attaches a new image processing configuration to the Standard Material.
  39802. * @param configuration
  39803. */
  39804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39805. /**
  39806. * Gets wether the color curves effect is enabled.
  39807. */
  39808. /**
  39809. * Sets wether the color curves effect is enabled.
  39810. */
  39811. cameraColorCurvesEnabled: boolean;
  39812. /**
  39813. * Gets wether the color grading effect is enabled.
  39814. */
  39815. /**
  39816. * Gets wether the color grading effect is enabled.
  39817. */
  39818. cameraColorGradingEnabled: boolean;
  39819. /**
  39820. * Gets wether tonemapping is enabled or not.
  39821. */
  39822. /**
  39823. * Sets wether tonemapping is enabled or not
  39824. */
  39825. cameraToneMappingEnabled: boolean;
  39826. /**
  39827. * The camera exposure used on this material.
  39828. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39829. * This corresponds to a photographic exposure.
  39830. */
  39831. /**
  39832. * The camera exposure used on this material.
  39833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39834. * This corresponds to a photographic exposure.
  39835. */
  39836. cameraExposure: number;
  39837. /**
  39838. * Gets The camera contrast used on this material.
  39839. */
  39840. /**
  39841. * Sets The camera contrast used on this material.
  39842. */
  39843. cameraContrast: number;
  39844. /**
  39845. * Gets the Color Grading 2D Lookup Texture.
  39846. */
  39847. /**
  39848. * Sets the Color Grading 2D Lookup Texture.
  39849. */
  39850. cameraColorGradingTexture: Nullable<BaseTexture>;
  39851. /**
  39852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39854. * 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;
  39855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39856. */
  39857. /**
  39858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39860. * 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;
  39861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39862. */
  39863. cameraColorCurves: Nullable<ColorCurves>;
  39864. /**
  39865. * Custom callback helping to override the default shader used in the material.
  39866. */
  39867. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39868. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39869. protected _worldViewProjectionMatrix: Matrix;
  39870. protected _globalAmbientColor: Color3;
  39871. protected _useLogarithmicDepth: boolean;
  39872. /**
  39873. * Instantiates a new standard material.
  39874. * This is the default material used in Babylon. It is the best trade off between quality
  39875. * and performances.
  39876. * @see http://doc.babylonjs.com/babylon101/materials
  39877. * @param name Define the name of the material in the scene
  39878. * @param scene Define the scene the material belong to
  39879. */
  39880. constructor(name: string, scene: Scene);
  39881. /**
  39882. * Gets a boolean indicating that current material needs to register RTT
  39883. */
  39884. readonly hasRenderTargetTextures: boolean;
  39885. /**
  39886. * Gets the current class name of the material e.g. "StandardMaterial"
  39887. * Mainly use in serialization.
  39888. * @returns the class name
  39889. */
  39890. getClassName(): string;
  39891. /**
  39892. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39893. * You can try switching to logarithmic depth.
  39894. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39895. */
  39896. useLogarithmicDepth: boolean;
  39897. /**
  39898. * Specifies if the material will require alpha blending
  39899. * @returns a boolean specifying if alpha blending is needed
  39900. */
  39901. needAlphaBlending(): boolean;
  39902. /**
  39903. * Specifies if this material should be rendered in alpha test mode
  39904. * @returns a boolean specifying if an alpha test is needed.
  39905. */
  39906. needAlphaTesting(): boolean;
  39907. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39908. /**
  39909. * Get the texture used for alpha test purpose.
  39910. * @returns the diffuse texture in case of the standard material.
  39911. */
  39912. getAlphaTestTexture(): Nullable<BaseTexture>;
  39913. /**
  39914. * Get if the submesh is ready to be used and all its information available.
  39915. * Child classes can use it to update shaders
  39916. * @param mesh defines the mesh to check
  39917. * @param subMesh defines which submesh to check
  39918. * @param useInstances specifies that instances should be used
  39919. * @returns a boolean indicating that the submesh is ready or not
  39920. */
  39921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39922. /**
  39923. * Builds the material UBO layouts.
  39924. * Used internally during the effect preparation.
  39925. */
  39926. buildUniformLayout(): void;
  39927. /**
  39928. * Unbinds the material from the mesh
  39929. */
  39930. unbind(): void;
  39931. /**
  39932. * Binds the submesh to this material by preparing the effect and shader to draw
  39933. * @param world defines the world transformation matrix
  39934. * @param mesh defines the mesh containing the submesh
  39935. * @param subMesh defines the submesh to bind the material to
  39936. */
  39937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39938. /**
  39939. * Get the list of animatables in the material.
  39940. * @returns the list of animatables object used in the material
  39941. */
  39942. getAnimatables(): IAnimatable[];
  39943. /**
  39944. * Gets the active textures from the material
  39945. * @returns an array of textures
  39946. */
  39947. getActiveTextures(): BaseTexture[];
  39948. /**
  39949. * Specifies if the material uses a texture
  39950. * @param texture defines the texture to check against the material
  39951. * @returns a boolean specifying if the material uses the texture
  39952. */
  39953. hasTexture(texture: BaseTexture): boolean;
  39954. /**
  39955. * Disposes the material
  39956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39958. */
  39959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39960. /**
  39961. * Makes a duplicate of the material, and gives it a new name
  39962. * @param name defines the new name for the duplicated material
  39963. * @returns the cloned material
  39964. */
  39965. clone(name: string): StandardMaterial;
  39966. /**
  39967. * Serializes this material in a JSON representation
  39968. * @returns the serialized material object
  39969. */
  39970. serialize(): any;
  39971. /**
  39972. * Creates a standard material from parsed material data
  39973. * @param source defines the JSON representation of the material
  39974. * @param scene defines the hosting scene
  39975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39976. * @returns a new standard material
  39977. */
  39978. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39979. /**
  39980. * Are diffuse textures enabled in the application.
  39981. */
  39982. static DiffuseTextureEnabled: boolean;
  39983. /**
  39984. * Are ambient textures enabled in the application.
  39985. */
  39986. static AmbientTextureEnabled: boolean;
  39987. /**
  39988. * Are opacity textures enabled in the application.
  39989. */
  39990. static OpacityTextureEnabled: boolean;
  39991. /**
  39992. * Are reflection textures enabled in the application.
  39993. */
  39994. static ReflectionTextureEnabled: boolean;
  39995. /**
  39996. * Are emissive textures enabled in the application.
  39997. */
  39998. static EmissiveTextureEnabled: boolean;
  39999. /**
  40000. * Are specular textures enabled in the application.
  40001. */
  40002. static SpecularTextureEnabled: boolean;
  40003. /**
  40004. * Are bump textures enabled in the application.
  40005. */
  40006. static BumpTextureEnabled: boolean;
  40007. /**
  40008. * Are lightmap textures enabled in the application.
  40009. */
  40010. static LightmapTextureEnabled: boolean;
  40011. /**
  40012. * Are refraction textures enabled in the application.
  40013. */
  40014. static RefractionTextureEnabled: boolean;
  40015. /**
  40016. * Are color grading textures enabled in the application.
  40017. */
  40018. static ColorGradingTextureEnabled: boolean;
  40019. /**
  40020. * Are fresnels enabled in the application.
  40021. */
  40022. static FresnelEnabled: boolean;
  40023. }
  40024. }
  40025. declare module BABYLON {
  40026. /**
  40027. * A class extending Texture allowing drawing on a texture
  40028. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40029. */
  40030. export class DynamicTexture extends Texture {
  40031. private _generateMipMaps;
  40032. private _canvas;
  40033. private _context;
  40034. private _engine;
  40035. /**
  40036. * Creates a DynamicTexture
  40037. * @param name defines the name of the texture
  40038. * @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
  40039. * @param scene defines the scene where you want the texture
  40040. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40041. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40042. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40043. */
  40044. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40045. /**
  40046. * Get the current class name of the texture useful for serialization or dynamic coding.
  40047. * @returns "DynamicTexture"
  40048. */
  40049. getClassName(): string;
  40050. /**
  40051. * Gets the current state of canRescale
  40052. */
  40053. readonly canRescale: boolean;
  40054. private _recreate;
  40055. /**
  40056. * Scales the texture
  40057. * @param ratio the scale factor to apply to both width and height
  40058. */
  40059. scale(ratio: number): void;
  40060. /**
  40061. * Resizes the texture
  40062. * @param width the new width
  40063. * @param height the new height
  40064. */
  40065. scaleTo(width: number, height: number): void;
  40066. /**
  40067. * Gets the context of the canvas used by the texture
  40068. * @returns the canvas context of the dynamic texture
  40069. */
  40070. getContext(): CanvasRenderingContext2D;
  40071. /**
  40072. * Clears the texture
  40073. */
  40074. clear(): void;
  40075. /**
  40076. * Updates the texture
  40077. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40078. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40079. */
  40080. update(invertY?: boolean, premulAlpha?: boolean): void;
  40081. /**
  40082. * Draws text onto the texture
  40083. * @param text defines the text to be drawn
  40084. * @param x defines the placement of the text from the left
  40085. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40086. * @param font defines the font to be used with font-style, font-size, font-name
  40087. * @param color defines the color used for the text
  40088. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40089. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40090. * @param update defines whether texture is immediately update (default is true)
  40091. */
  40092. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40093. /**
  40094. * Clones the texture
  40095. * @returns the clone of the texture.
  40096. */
  40097. clone(): DynamicTexture;
  40098. /**
  40099. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40100. * @returns a serialized dynamic texture object
  40101. */
  40102. serialize(): any;
  40103. /** @hidden */
  40104. _rebuild(): void;
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /** @hidden */
  40109. export var imageProcessingPixelShader: {
  40110. name: string;
  40111. shader: string;
  40112. };
  40113. }
  40114. declare module BABYLON {
  40115. /**
  40116. * ImageProcessingPostProcess
  40117. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40118. */
  40119. export class ImageProcessingPostProcess extends PostProcess {
  40120. /**
  40121. * Default configuration related to image processing available in the PBR Material.
  40122. */
  40123. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40124. /**
  40125. * Gets the image processing configuration used either in this material.
  40126. */
  40127. /**
  40128. * Sets the Default image processing configuration used either in the this material.
  40129. *
  40130. * If sets to null, the scene one is in use.
  40131. */
  40132. imageProcessingConfiguration: ImageProcessingConfiguration;
  40133. /**
  40134. * Keep track of the image processing observer to allow dispose and replace.
  40135. */
  40136. private _imageProcessingObserver;
  40137. /**
  40138. * Attaches a new image processing configuration to the PBR Material.
  40139. * @param configuration
  40140. */
  40141. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40142. /**
  40143. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40144. */
  40145. /**
  40146. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40147. */
  40148. colorCurves: Nullable<ColorCurves>;
  40149. /**
  40150. * Gets wether the color curves effect is enabled.
  40151. */
  40152. /**
  40153. * Sets wether the color curves effect is enabled.
  40154. */
  40155. colorCurvesEnabled: boolean;
  40156. /**
  40157. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40158. */
  40159. /**
  40160. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40161. */
  40162. colorGradingTexture: Nullable<BaseTexture>;
  40163. /**
  40164. * Gets wether the color grading effect is enabled.
  40165. */
  40166. /**
  40167. * Gets wether the color grading effect is enabled.
  40168. */
  40169. colorGradingEnabled: boolean;
  40170. /**
  40171. * Gets exposure used in the effect.
  40172. */
  40173. /**
  40174. * Sets exposure used in the effect.
  40175. */
  40176. exposure: number;
  40177. /**
  40178. * Gets wether tonemapping is enabled or not.
  40179. */
  40180. /**
  40181. * Sets wether tonemapping is enabled or not
  40182. */
  40183. toneMappingEnabled: boolean;
  40184. /**
  40185. * Gets the type of tone mapping effect.
  40186. */
  40187. /**
  40188. * Sets the type of tone mapping effect.
  40189. */
  40190. toneMappingType: number;
  40191. /**
  40192. * Gets contrast used in the effect.
  40193. */
  40194. /**
  40195. * Sets contrast used in the effect.
  40196. */
  40197. contrast: number;
  40198. /**
  40199. * Gets Vignette stretch size.
  40200. */
  40201. /**
  40202. * Sets Vignette stretch size.
  40203. */
  40204. vignetteStretch: number;
  40205. /**
  40206. * Gets Vignette centre X Offset.
  40207. */
  40208. /**
  40209. * Sets Vignette centre X Offset.
  40210. */
  40211. vignetteCentreX: number;
  40212. /**
  40213. * Gets Vignette centre Y Offset.
  40214. */
  40215. /**
  40216. * Sets Vignette centre Y Offset.
  40217. */
  40218. vignetteCentreY: number;
  40219. /**
  40220. * Gets Vignette weight or intensity of the vignette effect.
  40221. */
  40222. /**
  40223. * Sets Vignette weight or intensity of the vignette effect.
  40224. */
  40225. vignetteWeight: number;
  40226. /**
  40227. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40228. * if vignetteEnabled is set to true.
  40229. */
  40230. /**
  40231. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40232. * if vignetteEnabled is set to true.
  40233. */
  40234. vignetteColor: Color4;
  40235. /**
  40236. * Gets Camera field of view used by the Vignette effect.
  40237. */
  40238. /**
  40239. * Sets Camera field of view used by the Vignette effect.
  40240. */
  40241. vignetteCameraFov: number;
  40242. /**
  40243. * Gets the vignette blend mode allowing different kind of effect.
  40244. */
  40245. /**
  40246. * Sets the vignette blend mode allowing different kind of effect.
  40247. */
  40248. vignetteBlendMode: number;
  40249. /**
  40250. * Gets wether the vignette effect is enabled.
  40251. */
  40252. /**
  40253. * Sets wether the vignette effect is enabled.
  40254. */
  40255. vignetteEnabled: boolean;
  40256. private _fromLinearSpace;
  40257. /**
  40258. * Gets wether the input of the processing is in Gamma or Linear Space.
  40259. */
  40260. /**
  40261. * Sets wether the input of the processing is in Gamma or Linear Space.
  40262. */
  40263. fromLinearSpace: boolean;
  40264. /**
  40265. * Defines cache preventing GC.
  40266. */
  40267. private _defines;
  40268. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40269. /**
  40270. * "ImageProcessingPostProcess"
  40271. * @returns "ImageProcessingPostProcess"
  40272. */
  40273. getClassName(): string;
  40274. protected _updateParameters(): void;
  40275. dispose(camera?: Camera): void;
  40276. }
  40277. }
  40278. declare module BABYLON {
  40279. /**
  40280. * Class containing static functions to help procedurally build meshes
  40281. */
  40282. export class GroundBuilder {
  40283. /**
  40284. * Creates a ground mesh
  40285. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40286. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40288. * @param name defines the name of the mesh
  40289. * @param options defines the options used to create the mesh
  40290. * @param scene defines the hosting scene
  40291. * @returns the ground mesh
  40292. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40293. */
  40294. static CreateGround(name: string, options: {
  40295. width?: number;
  40296. height?: number;
  40297. subdivisions?: number;
  40298. subdivisionsX?: number;
  40299. subdivisionsY?: number;
  40300. updatable?: boolean;
  40301. }, scene: any): Mesh;
  40302. /**
  40303. * Creates a tiled ground mesh
  40304. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40305. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40306. * * 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
  40307. * * 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
  40308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40309. * @param name defines the name of the mesh
  40310. * @param options defines the options used to create the mesh
  40311. * @param scene defines the hosting scene
  40312. * @returns the tiled ground mesh
  40313. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40314. */
  40315. static CreateTiledGround(name: string, options: {
  40316. xmin: number;
  40317. zmin: number;
  40318. xmax: number;
  40319. zmax: number;
  40320. subdivisions?: {
  40321. w: number;
  40322. h: number;
  40323. };
  40324. precision?: {
  40325. w: number;
  40326. h: number;
  40327. };
  40328. updatable?: boolean;
  40329. }, scene?: Nullable<Scene>): Mesh;
  40330. /**
  40331. * Creates a ground mesh from a height map
  40332. * * The parameter `url` sets the URL of the height map image resource.
  40333. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40334. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40335. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40336. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40337. * * 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.
  40338. * * 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).
  40339. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40341. * @param name defines the name of the mesh
  40342. * @param url defines the url to the height map
  40343. * @param options defines the options used to create the mesh
  40344. * @param scene defines the hosting scene
  40345. * @returns the ground mesh
  40346. * @see https://doc.babylonjs.com/babylon101/height_map
  40347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40348. */
  40349. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40350. width?: number;
  40351. height?: number;
  40352. subdivisions?: number;
  40353. minHeight?: number;
  40354. maxHeight?: number;
  40355. colorFilter?: Color3;
  40356. alphaFilter?: number;
  40357. updatable?: boolean;
  40358. onReady?: (mesh: GroundMesh) => void;
  40359. }, scene?: Nullable<Scene>): GroundMesh;
  40360. }
  40361. }
  40362. declare module BABYLON {
  40363. /**
  40364. * Class containing static functions to help procedurally build meshes
  40365. */
  40366. export class TorusBuilder {
  40367. /**
  40368. * Creates a torus mesh
  40369. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40370. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40371. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40373. * * 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
  40374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40375. * @param name defines the name of the mesh
  40376. * @param options defines the options used to create the mesh
  40377. * @param scene defines the hosting scene
  40378. * @returns the torus mesh
  40379. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40380. */
  40381. static CreateTorus(name: string, options: {
  40382. diameter?: number;
  40383. thickness?: number;
  40384. tessellation?: number;
  40385. updatable?: boolean;
  40386. sideOrientation?: number;
  40387. frontUVs?: Vector4;
  40388. backUVs?: Vector4;
  40389. }, scene: any): Mesh;
  40390. }
  40391. }
  40392. declare module BABYLON {
  40393. /**
  40394. * Class containing static functions to help procedurally build meshes
  40395. */
  40396. export class CylinderBuilder {
  40397. /**
  40398. * Creates a cylinder or a cone mesh
  40399. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40400. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40401. * * 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.
  40402. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40403. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40404. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40405. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40406. * * 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).
  40407. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40408. * * 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).
  40409. * * 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
  40410. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40411. * * 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
  40412. * * 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.
  40413. * * If `enclose` is false, a ring surface is one element.
  40414. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40415. * * 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
  40416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40417. * * 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
  40418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40419. * @param name defines the name of the mesh
  40420. * @param options defines the options used to create the mesh
  40421. * @param scene defines the hosting scene
  40422. * @returns the cylinder mesh
  40423. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40424. */
  40425. static CreateCylinder(name: string, options: {
  40426. height?: number;
  40427. diameterTop?: number;
  40428. diameterBottom?: number;
  40429. diameter?: number;
  40430. tessellation?: number;
  40431. subdivisions?: number;
  40432. arc?: number;
  40433. faceColors?: Color4[];
  40434. faceUV?: Vector4[];
  40435. updatable?: boolean;
  40436. hasRings?: boolean;
  40437. enclose?: boolean;
  40438. cap?: number;
  40439. sideOrientation?: number;
  40440. frontUVs?: Vector4;
  40441. backUVs?: Vector4;
  40442. }, scene: any): Mesh;
  40443. }
  40444. }
  40445. declare module BABYLON {
  40446. /**
  40447. * Options to modify the vr teleportation behavior.
  40448. */
  40449. export interface VRTeleportationOptions {
  40450. /**
  40451. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40452. */
  40453. floorMeshName?: string;
  40454. /**
  40455. * A list of meshes to be used as the teleportation floor. (default: empty)
  40456. */
  40457. floorMeshes?: Mesh[];
  40458. }
  40459. /**
  40460. * Options to modify the vr experience helper's behavior.
  40461. */
  40462. export interface VRExperienceHelperOptions extends WebVROptions {
  40463. /**
  40464. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40465. */
  40466. createDeviceOrientationCamera?: boolean;
  40467. /**
  40468. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40469. */
  40470. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40471. /**
  40472. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40473. */
  40474. laserToggle?: boolean;
  40475. /**
  40476. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40477. */
  40478. floorMeshes?: Mesh[];
  40479. /**
  40480. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40481. */
  40482. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40483. }
  40484. /**
  40485. * Event containing information after VR has been entered
  40486. */
  40487. export class OnAfterEnteringVRObservableEvent {
  40488. /**
  40489. * If entering vr was successful
  40490. */
  40491. success: boolean;
  40492. }
  40493. /**
  40494. * Helps to quickly add VR support to an existing scene.
  40495. * See http://doc.babylonjs.com/how_to/webvr_helper
  40496. */
  40497. export class VRExperienceHelper {
  40498. /** Options to modify the vr experience helper's behavior. */
  40499. webVROptions: VRExperienceHelperOptions;
  40500. private _scene;
  40501. private _position;
  40502. private _btnVR;
  40503. private _btnVRDisplayed;
  40504. private _webVRsupported;
  40505. private _webVRready;
  40506. private _webVRrequesting;
  40507. private _webVRpresenting;
  40508. private _hasEnteredVR;
  40509. private _fullscreenVRpresenting;
  40510. private _canvas;
  40511. private _webVRCamera;
  40512. private _vrDeviceOrientationCamera;
  40513. private _deviceOrientationCamera;
  40514. private _existingCamera;
  40515. private _onKeyDown;
  40516. private _onVrDisplayPresentChange;
  40517. private _onVRDisplayChanged;
  40518. private _onVRRequestPresentStart;
  40519. private _onVRRequestPresentComplete;
  40520. /**
  40521. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40522. */
  40523. enableGazeEvenWhenNoPointerLock: boolean;
  40524. /**
  40525. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40526. */
  40527. exitVROnDoubleTap: boolean;
  40528. /**
  40529. * Observable raised right before entering VR.
  40530. */
  40531. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40532. /**
  40533. * Observable raised when entering VR has completed.
  40534. */
  40535. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40536. /**
  40537. * Observable raised when exiting VR.
  40538. */
  40539. onExitingVRObservable: Observable<VRExperienceHelper>;
  40540. /**
  40541. * Observable raised when controller mesh is loaded.
  40542. */
  40543. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40544. /** Return this.onEnteringVRObservable
  40545. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40546. */
  40547. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40548. /** Return this.onExitingVRObservable
  40549. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40550. */
  40551. readonly onExitingVR: Observable<VRExperienceHelper>;
  40552. /** Return this.onControllerMeshLoadedObservable
  40553. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40554. */
  40555. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40556. private _rayLength;
  40557. private _useCustomVRButton;
  40558. private _teleportationRequested;
  40559. private _teleportActive;
  40560. private _floorMeshName;
  40561. private _floorMeshesCollection;
  40562. private _rotationAllowed;
  40563. private _teleportBackwardsVector;
  40564. private _teleportationTarget;
  40565. private _isDefaultTeleportationTarget;
  40566. private _postProcessMove;
  40567. private _teleportationFillColor;
  40568. private _teleportationBorderColor;
  40569. private _rotationAngle;
  40570. private _haloCenter;
  40571. private _cameraGazer;
  40572. private _padSensibilityUp;
  40573. private _padSensibilityDown;
  40574. private _leftController;
  40575. private _rightController;
  40576. /**
  40577. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40578. */
  40579. onNewMeshSelected: Observable<AbstractMesh>;
  40580. /**
  40581. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40582. */
  40583. onNewMeshPicked: Observable<PickingInfo>;
  40584. private _circleEase;
  40585. /**
  40586. * Observable raised before camera teleportation
  40587. */
  40588. onBeforeCameraTeleport: Observable<Vector3>;
  40589. /**
  40590. * Observable raised after camera teleportation
  40591. */
  40592. onAfterCameraTeleport: Observable<Vector3>;
  40593. /**
  40594. * Observable raised when current selected mesh gets unselected
  40595. */
  40596. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40597. private _raySelectionPredicate;
  40598. /**
  40599. * To be optionaly changed by user to define custom ray selection
  40600. */
  40601. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40602. /**
  40603. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40604. */
  40605. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40606. /**
  40607. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40608. */
  40609. teleportationEnabled: boolean;
  40610. private _defaultHeight;
  40611. private _teleportationInitialized;
  40612. private _interactionsEnabled;
  40613. private _interactionsRequested;
  40614. private _displayGaze;
  40615. private _displayLaserPointer;
  40616. /**
  40617. * The mesh used to display where the user is going to teleport.
  40618. */
  40619. /**
  40620. * Sets the mesh to be used to display where the user is going to teleport.
  40621. */
  40622. teleportationTarget: Mesh;
  40623. /**
  40624. * 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
  40625. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40626. * See http://doc.babylonjs.com/resources/baking_transformations
  40627. */
  40628. gazeTrackerMesh: Mesh;
  40629. /**
  40630. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40631. */
  40632. updateGazeTrackerScale: boolean;
  40633. /**
  40634. * If the gaze trackers color should be updated when selecting meshes
  40635. */
  40636. updateGazeTrackerColor: boolean;
  40637. /**
  40638. * The gaze tracking mesh corresponding to the left controller
  40639. */
  40640. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40641. /**
  40642. * The gaze tracking mesh corresponding to the right controller
  40643. */
  40644. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40645. /**
  40646. * If the ray of the gaze should be displayed.
  40647. */
  40648. /**
  40649. * Sets if the ray of the gaze should be displayed.
  40650. */
  40651. displayGaze: boolean;
  40652. /**
  40653. * If the ray of the LaserPointer should be displayed.
  40654. */
  40655. /**
  40656. * Sets if the ray of the LaserPointer should be displayed.
  40657. */
  40658. displayLaserPointer: boolean;
  40659. /**
  40660. * The deviceOrientationCamera used as the camera when not in VR.
  40661. */
  40662. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40663. /**
  40664. * Based on the current WebVR support, returns the current VR camera used.
  40665. */
  40666. readonly currentVRCamera: Nullable<Camera>;
  40667. /**
  40668. * The webVRCamera which is used when in VR.
  40669. */
  40670. readonly webVRCamera: WebVRFreeCamera;
  40671. /**
  40672. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40673. */
  40674. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40675. /**
  40676. * The html button that is used to trigger entering into VR.
  40677. */
  40678. readonly vrButton: Nullable<HTMLButtonElement>;
  40679. private readonly _teleportationRequestInitiated;
  40680. /**
  40681. * Defines wether or not Pointer lock should be requested when switching to
  40682. * full screen.
  40683. */
  40684. requestPointerLockOnFullScreen: boolean;
  40685. /**
  40686. * Instantiates a VRExperienceHelper.
  40687. * Helps to quickly add VR support to an existing scene.
  40688. * @param scene The scene the VRExperienceHelper belongs to.
  40689. * @param webVROptions Options to modify the vr experience helper's behavior.
  40690. */
  40691. constructor(scene: Scene,
  40692. /** Options to modify the vr experience helper's behavior. */
  40693. webVROptions?: VRExperienceHelperOptions);
  40694. private _onDefaultMeshLoaded;
  40695. private _onResize;
  40696. private _onFullscreenChange;
  40697. /**
  40698. * Gets a value indicating if we are currently in VR mode.
  40699. */
  40700. readonly isInVRMode: boolean;
  40701. private onVrDisplayPresentChange;
  40702. private onVRDisplayChanged;
  40703. private moveButtonToBottomRight;
  40704. private displayVRButton;
  40705. private updateButtonVisibility;
  40706. private _cachedAngularSensibility;
  40707. /**
  40708. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40709. * Otherwise, will use the fullscreen API.
  40710. */
  40711. enterVR(): void;
  40712. /**
  40713. * Attempt to exit VR, or fullscreen.
  40714. */
  40715. exitVR(): void;
  40716. /**
  40717. * The position of the vr experience helper.
  40718. */
  40719. /**
  40720. * Sets the position of the vr experience helper.
  40721. */
  40722. position: Vector3;
  40723. /**
  40724. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40725. */
  40726. enableInteractions(): void;
  40727. private readonly _noControllerIsActive;
  40728. private beforeRender;
  40729. private _isTeleportationFloor;
  40730. /**
  40731. * Adds a floor mesh to be used for teleportation.
  40732. * @param floorMesh the mesh to be used for teleportation.
  40733. */
  40734. addFloorMesh(floorMesh: Mesh): void;
  40735. /**
  40736. * Removes a floor mesh from being used for teleportation.
  40737. * @param floorMesh the mesh to be removed.
  40738. */
  40739. removeFloorMesh(floorMesh: Mesh): void;
  40740. /**
  40741. * Enables interactions and teleportation using the VR controllers and gaze.
  40742. * @param vrTeleportationOptions options to modify teleportation behavior.
  40743. */
  40744. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40745. private _onNewGamepadConnected;
  40746. private _tryEnableInteractionOnController;
  40747. private _onNewGamepadDisconnected;
  40748. private _enableInteractionOnController;
  40749. private _checkTeleportWithRay;
  40750. private _checkRotate;
  40751. private _checkTeleportBackwards;
  40752. private _enableTeleportationOnController;
  40753. private _createTeleportationCircles;
  40754. private _displayTeleportationTarget;
  40755. private _hideTeleportationTarget;
  40756. private _rotateCamera;
  40757. private _moveTeleportationSelectorTo;
  40758. private _workingVector;
  40759. private _workingQuaternion;
  40760. private _workingMatrix;
  40761. /**
  40762. * Teleports the users feet to the desired location
  40763. * @param location The location where the user's feet should be placed
  40764. */
  40765. teleportCamera(location: Vector3): void;
  40766. private _convertNormalToDirectionOfRay;
  40767. private _castRayAndSelectObject;
  40768. private _notifySelectedMeshUnselected;
  40769. /**
  40770. * Sets the color of the laser ray from the vr controllers.
  40771. * @param color new color for the ray.
  40772. */
  40773. changeLaserColor(color: Color3): void;
  40774. /**
  40775. * Sets the color of the ray from the vr headsets gaze.
  40776. * @param color new color for the ray.
  40777. */
  40778. changeGazeColor(color: Color3): void;
  40779. /**
  40780. * Exits VR and disposes of the vr experience helper
  40781. */
  40782. dispose(): void;
  40783. /**
  40784. * Gets the name of the VRExperienceHelper class
  40785. * @returns "VRExperienceHelper"
  40786. */
  40787. getClassName(): string;
  40788. }
  40789. }
  40790. declare module BABYLON {
  40791. /**
  40792. * Manages an XRSession to work with Babylon's engine
  40793. * @see https://doc.babylonjs.com/how_to/webxr
  40794. */
  40795. export class WebXRSessionManager implements IDisposable {
  40796. private scene;
  40797. /**
  40798. * Fires every time a new xrFrame arrives which can be used to update the camera
  40799. */
  40800. onXRFrameObservable: Observable<any>;
  40801. /**
  40802. * Fires when the xr session is ended either by the device or manually done
  40803. */
  40804. onXRSessionEnded: Observable<any>;
  40805. /**
  40806. * Underlying xr session
  40807. */
  40808. session: XRSession;
  40809. /**
  40810. * Type of reference space used when creating the session
  40811. */
  40812. referenceSpace: XRReferenceSpace;
  40813. /** @hidden */
  40814. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40815. /**
  40816. * Current XR frame
  40817. */
  40818. currentFrame: Nullable<XRFrame>;
  40819. private _xrNavigator;
  40820. private baseLayer;
  40821. /**
  40822. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40823. * @param scene The scene which the session should be created for
  40824. */
  40825. constructor(scene: Scene);
  40826. /**
  40827. * Initializes the manager
  40828. * After initialization enterXR can be called to start an XR session
  40829. * @returns Promise which resolves after it is initialized
  40830. */
  40831. initializeAsync(): Promise<void>;
  40832. /**
  40833. * Initializes an xr session
  40834. * @param xrSessionMode mode to initialize
  40835. * @returns a promise which will resolve once the session has been initialized
  40836. */
  40837. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40838. /**
  40839. * Sets the reference space on the xr session
  40840. * @param referenceSpace space to set
  40841. * @returns a promise that will resolve once the reference space has been set
  40842. */
  40843. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40844. /**
  40845. * Updates the render state of the session
  40846. * @param state state to set
  40847. * @returns a promise that resolves once the render state has been updated
  40848. */
  40849. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40850. /**
  40851. * Starts rendering to the xr layer
  40852. * @returns a promise that will resolve once rendering has started
  40853. */
  40854. startRenderingToXRAsync(): Promise<void>;
  40855. /**
  40856. * Stops the xrSession and restores the renderloop
  40857. * @returns Promise which resolves after it exits XR
  40858. */
  40859. exitXRAsync(): Promise<unknown>;
  40860. /**
  40861. * Checks if a session would be supported for the creation options specified
  40862. * @param sessionMode session mode to check if supported eg. immersive-vr
  40863. * @returns true if supported
  40864. */
  40865. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40866. /**
  40867. * @hidden
  40868. * Converts the render layer of xrSession to a render target
  40869. * @param session session to create render target for
  40870. * @param scene scene the new render target should be created for
  40871. */
  40872. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40873. /**
  40874. * Disposes of the session manager
  40875. */
  40876. dispose(): void;
  40877. }
  40878. }
  40879. declare module BABYLON {
  40880. /**
  40881. * WebXR Camera which holds the views for the xrSession
  40882. * @see https://doc.babylonjs.com/how_to/webxr
  40883. */
  40884. export class WebXRCamera extends FreeCamera {
  40885. private static _TmpMatrix;
  40886. /**
  40887. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40888. * @param name the name of the camera
  40889. * @param scene the scene to add the camera to
  40890. */
  40891. constructor(name: string, scene: Scene);
  40892. private _updateNumberOfRigCameras;
  40893. /** @hidden */
  40894. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40895. /**
  40896. * Updates the cameras position from the current pose information of the XR session
  40897. * @param xrSessionManager the session containing pose information
  40898. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40899. */
  40900. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40901. }
  40902. }
  40903. declare module BABYLON {
  40904. /**
  40905. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40906. */
  40907. export class WebXRManagedOutputCanvas implements IDisposable {
  40908. private helper;
  40909. private _canvas;
  40910. /**
  40911. * xrpresent context of the canvas which can be used to display/mirror xr content
  40912. */
  40913. canvasContext: WebGLRenderingContext;
  40914. /**
  40915. * xr layer for the canvas
  40916. */
  40917. xrLayer: Nullable<XRWebGLLayer>;
  40918. /**
  40919. * Initializes the xr layer for the session
  40920. * @param xrSession xr session
  40921. * @returns a promise that will resolve once the XR Layer has been created
  40922. */
  40923. initializeXRLayerAsync(xrSession: any): any;
  40924. /**
  40925. * Initializes the canvas to be added/removed upon entering/exiting xr
  40926. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40927. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40928. */
  40929. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40930. /**
  40931. * Disposes of the object
  40932. */
  40933. dispose(): void;
  40934. private _setManagedOutputCanvas;
  40935. private _addCanvas;
  40936. private _removeCanvas;
  40937. }
  40938. }
  40939. declare module BABYLON {
  40940. /**
  40941. * States of the webXR experience
  40942. */
  40943. export enum WebXRState {
  40944. /**
  40945. * Transitioning to being in XR mode
  40946. */
  40947. ENTERING_XR = 0,
  40948. /**
  40949. * Transitioning to non XR mode
  40950. */
  40951. EXITING_XR = 1,
  40952. /**
  40953. * In XR mode and presenting
  40954. */
  40955. IN_XR = 2,
  40956. /**
  40957. * Not entered XR mode
  40958. */
  40959. NOT_IN_XR = 3
  40960. }
  40961. /**
  40962. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40963. * @see https://doc.babylonjs.com/how_to/webxr
  40964. */
  40965. export class WebXRExperienceHelper implements IDisposable {
  40966. private scene;
  40967. /**
  40968. * 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
  40969. */
  40970. container: AbstractMesh;
  40971. /**
  40972. * Camera used to render xr content
  40973. */
  40974. camera: WebXRCamera;
  40975. /**
  40976. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40977. */
  40978. state: WebXRState;
  40979. private _setState;
  40980. private static _TmpVector;
  40981. /**
  40982. * Fires when the state of the experience helper has changed
  40983. */
  40984. onStateChangedObservable: Observable<WebXRState>;
  40985. /** Session manager used to keep track of xr session */
  40986. sessionManager: WebXRSessionManager;
  40987. private _nonVRCamera;
  40988. private _originalSceneAutoClear;
  40989. private _supported;
  40990. /**
  40991. * Creates the experience helper
  40992. * @param scene the scene to attach the experience helper to
  40993. * @returns a promise for the experience helper
  40994. */
  40995. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40996. /**
  40997. * Creates a WebXRExperienceHelper
  40998. * @param scene The scene the helper should be created in
  40999. */
  41000. private constructor();
  41001. /**
  41002. * Exits XR mode and returns the scene to its original state
  41003. * @returns promise that resolves after xr mode has exited
  41004. */
  41005. exitXRAsync(): Promise<unknown>;
  41006. /**
  41007. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41008. * @param sessionCreationOptions options for the XR session
  41009. * @param referenceSpaceType frame of reference of the XR session
  41010. * @param outputCanvas the output canvas that will be used to enter XR mode
  41011. * @returns promise that resolves after xr mode has entered
  41012. */
  41013. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41014. /**
  41015. * Updates the global position of the camera by moving the camera's container
  41016. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41017. * @param position The desired global position of the camera
  41018. */
  41019. setPositionOfCameraUsingContainer(position: Vector3): void;
  41020. /**
  41021. * Rotates the xr camera by rotating the camera's container around the camera's position
  41022. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41023. * @param rotation the desired quaternion rotation to apply to the camera
  41024. */
  41025. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41026. /**
  41027. * Disposes of the experience helper
  41028. */
  41029. dispose(): void;
  41030. }
  41031. }
  41032. declare module BABYLON {
  41033. /**
  41034. * Button which can be used to enter a different mode of XR
  41035. */
  41036. export class WebXREnterExitUIButton {
  41037. /** button element */
  41038. element: HTMLElement;
  41039. /** XR initialization options for the button */
  41040. sessionMode: XRSessionMode;
  41041. /** Reference space type */
  41042. referenceSpaceType: XRReferenceSpaceType;
  41043. /**
  41044. * Creates a WebXREnterExitUIButton
  41045. * @param element button element
  41046. * @param sessionMode XR initialization session mode
  41047. * @param referenceSpaceType the type of reference space to be used
  41048. */
  41049. constructor(
  41050. /** button element */
  41051. element: HTMLElement,
  41052. /** XR initialization options for the button */
  41053. sessionMode: XRSessionMode,
  41054. /** Reference space type */
  41055. referenceSpaceType: XRReferenceSpaceType);
  41056. /**
  41057. * Overwritable function which can be used to update the button's visuals when the state changes
  41058. * @param activeButton the current active button in the UI
  41059. */
  41060. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41061. }
  41062. /**
  41063. * Options to create the webXR UI
  41064. */
  41065. export class WebXREnterExitUIOptions {
  41066. /**
  41067. * Context to enter xr with
  41068. */
  41069. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41070. /**
  41071. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41072. */
  41073. customButtons?: Array<WebXREnterExitUIButton>;
  41074. }
  41075. /**
  41076. * UI to allow the user to enter/exit XR mode
  41077. */
  41078. export class WebXREnterExitUI implements IDisposable {
  41079. private scene;
  41080. private _overlay;
  41081. private _buttons;
  41082. private _activeButton;
  41083. /**
  41084. * Fired every time the active button is changed.
  41085. *
  41086. * When xr is entered via a button that launches xr that button will be the callback parameter
  41087. *
  41088. * When exiting xr the callback parameter will be null)
  41089. */
  41090. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41091. /**
  41092. * Creates UI to allow the user to enter/exit XR mode
  41093. * @param scene the scene to add the ui to
  41094. * @param helper the xr experience helper to enter/exit xr with
  41095. * @param options options to configure the UI
  41096. * @returns the created ui
  41097. */
  41098. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41099. private constructor();
  41100. private _updateButtons;
  41101. /**
  41102. * Disposes of the object
  41103. */
  41104. dispose(): void;
  41105. }
  41106. }
  41107. declare module BABYLON {
  41108. /**
  41109. * Represents an XR input
  41110. */
  41111. export class WebXRController {
  41112. private scene;
  41113. /** The underlying input source for the controller */
  41114. inputSource: XRInputSource;
  41115. private parentContainer;
  41116. /**
  41117. * 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
  41118. */
  41119. grip?: AbstractMesh;
  41120. /**
  41121. * Pointer which can be used to select objects or attach a visible laser to
  41122. */
  41123. pointer: AbstractMesh;
  41124. /**
  41125. * Event that fires when the controller is removed/disposed
  41126. */
  41127. onDisposeObservable: Observable<{}>;
  41128. private _tmpMatrix;
  41129. private _tmpQuaternion;
  41130. private _tmpVector;
  41131. /**
  41132. * Creates the controller
  41133. * @see https://doc.babylonjs.com/how_to/webxr
  41134. * @param scene the scene which the controller should be associated to
  41135. * @param inputSource the underlying input source for the controller
  41136. * @param parentContainer parent that the controller meshes should be children of
  41137. */
  41138. constructor(scene: Scene,
  41139. /** The underlying input source for the controller */
  41140. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41141. /**
  41142. * Updates the controller pose based on the given XRFrame
  41143. * @param xrFrame xr frame to update the pose with
  41144. * @param referenceSpace reference space to use
  41145. */
  41146. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41147. /**
  41148. * Gets a world space ray coming from the controller
  41149. * @param result the resulting ray
  41150. */
  41151. getWorldPointerRayToRef(result: Ray): void;
  41152. /**
  41153. * Disposes of the object
  41154. */
  41155. dispose(): void;
  41156. }
  41157. }
  41158. declare module BABYLON {
  41159. /**
  41160. * XR input used to track XR inputs such as controllers/rays
  41161. */
  41162. export class WebXRInput implements IDisposable {
  41163. /**
  41164. * Base experience the input listens to
  41165. */
  41166. baseExperience: WebXRExperienceHelper;
  41167. /**
  41168. * XR controllers being tracked
  41169. */
  41170. controllers: Array<WebXRController>;
  41171. private _frameObserver;
  41172. private _stateObserver;
  41173. /**
  41174. * Event when a controller has been connected/added
  41175. */
  41176. onControllerAddedObservable: Observable<WebXRController>;
  41177. /**
  41178. * Event when a controller has been removed/disconnected
  41179. */
  41180. onControllerRemovedObservable: Observable<WebXRController>;
  41181. /**
  41182. * Initializes the WebXRInput
  41183. * @param baseExperience experience helper which the input should be created for
  41184. */
  41185. constructor(
  41186. /**
  41187. * Base experience the input listens to
  41188. */
  41189. baseExperience: WebXRExperienceHelper);
  41190. private _onInputSourcesChange;
  41191. private _addAndRemoveControllers;
  41192. /**
  41193. * Disposes of the object
  41194. */
  41195. dispose(): void;
  41196. }
  41197. }
  41198. declare module BABYLON {
  41199. /**
  41200. * Enables teleportation
  41201. */
  41202. export class WebXRControllerTeleportation {
  41203. private _teleportationFillColor;
  41204. private _teleportationBorderColor;
  41205. private _tmpRay;
  41206. private _tmpVector;
  41207. /**
  41208. * Creates a WebXRControllerTeleportation
  41209. * @param input input manager to add teleportation to
  41210. * @param floorMeshes floormeshes which can be teleported to
  41211. */
  41212. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41213. }
  41214. }
  41215. declare module BABYLON {
  41216. /**
  41217. * Handles pointer input automatically for the pointer of XR controllers
  41218. */
  41219. export class WebXRControllerPointerSelection {
  41220. private static _idCounter;
  41221. private _tmpRay;
  41222. /**
  41223. * Creates a WebXRControllerPointerSelection
  41224. * @param input input manager to setup pointer selection
  41225. */
  41226. constructor(input: WebXRInput);
  41227. private _convertNormalToDirectionOfRay;
  41228. private _updatePointerDistance;
  41229. }
  41230. }
  41231. declare module BABYLON {
  41232. /**
  41233. * Class used to represent data loading progression
  41234. */
  41235. export class SceneLoaderProgressEvent {
  41236. /** defines if data length to load can be evaluated */
  41237. readonly lengthComputable: boolean;
  41238. /** defines the loaded data length */
  41239. readonly loaded: number;
  41240. /** defines the data length to load */
  41241. readonly total: number;
  41242. /**
  41243. * Create a new progress event
  41244. * @param lengthComputable defines if data length to load can be evaluated
  41245. * @param loaded defines the loaded data length
  41246. * @param total defines the data length to load
  41247. */
  41248. constructor(
  41249. /** defines if data length to load can be evaluated */
  41250. lengthComputable: boolean,
  41251. /** defines the loaded data length */
  41252. loaded: number,
  41253. /** defines the data length to load */
  41254. total: number);
  41255. /**
  41256. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41257. * @param event defines the source event
  41258. * @returns a new SceneLoaderProgressEvent
  41259. */
  41260. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41261. }
  41262. /**
  41263. * Interface used by SceneLoader plugins to define supported file extensions
  41264. */
  41265. export interface ISceneLoaderPluginExtensions {
  41266. /**
  41267. * Defines the list of supported extensions
  41268. */
  41269. [extension: string]: {
  41270. isBinary: boolean;
  41271. };
  41272. }
  41273. /**
  41274. * Interface used by SceneLoader plugin factory
  41275. */
  41276. export interface ISceneLoaderPluginFactory {
  41277. /**
  41278. * Defines the name of the factory
  41279. */
  41280. name: string;
  41281. /**
  41282. * Function called to create a new plugin
  41283. * @return the new plugin
  41284. */
  41285. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41286. /**
  41287. * Boolean indicating if the plugin can direct load specific data
  41288. */
  41289. canDirectLoad?: (data: string) => boolean;
  41290. }
  41291. /**
  41292. * Interface used to define a SceneLoader plugin
  41293. */
  41294. export interface ISceneLoaderPlugin {
  41295. /**
  41296. * The friendly name of this plugin.
  41297. */
  41298. name: string;
  41299. /**
  41300. * The file extensions supported by this plugin.
  41301. */
  41302. extensions: string | ISceneLoaderPluginExtensions;
  41303. /**
  41304. * Import meshes into a scene.
  41305. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41306. * @param scene The scene to import into
  41307. * @param data The data to import
  41308. * @param rootUrl The root url for scene and resources
  41309. * @param meshes The meshes array to import into
  41310. * @param particleSystems The particle systems array to import into
  41311. * @param skeletons The skeletons array to import into
  41312. * @param onError The callback when import fails
  41313. * @returns True if successful or false otherwise
  41314. */
  41315. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41316. /**
  41317. * Load into a scene.
  41318. * @param scene The scene to load into
  41319. * @param data The data to import
  41320. * @param rootUrl The root url for scene and resources
  41321. * @param onError The callback when import fails
  41322. * @returns true if successful or false otherwise
  41323. */
  41324. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41325. /**
  41326. * The callback that returns true if the data can be directly loaded.
  41327. */
  41328. canDirectLoad?: (data: string) => boolean;
  41329. /**
  41330. * The callback that allows custom handling of the root url based on the response url.
  41331. */
  41332. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41333. /**
  41334. * Load into an asset container.
  41335. * @param scene The scene to load into
  41336. * @param data The data to import
  41337. * @param rootUrl The root url for scene and resources
  41338. * @param onError The callback when import fails
  41339. * @returns The loaded asset container
  41340. */
  41341. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41342. }
  41343. /**
  41344. * Interface used to define an async SceneLoader plugin
  41345. */
  41346. export interface ISceneLoaderPluginAsync {
  41347. /**
  41348. * The friendly name of this plugin.
  41349. */
  41350. name: string;
  41351. /**
  41352. * The file extensions supported by this plugin.
  41353. */
  41354. extensions: string | ISceneLoaderPluginExtensions;
  41355. /**
  41356. * Import meshes into a scene.
  41357. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41358. * @param scene The scene to import into
  41359. * @param data The data to import
  41360. * @param rootUrl The root url for scene and resources
  41361. * @param onProgress The callback when the load progresses
  41362. * @param fileName Defines the name of the file to load
  41363. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41364. */
  41365. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41366. meshes: AbstractMesh[];
  41367. particleSystems: IParticleSystem[];
  41368. skeletons: Skeleton[];
  41369. animationGroups: AnimationGroup[];
  41370. }>;
  41371. /**
  41372. * Load into a scene.
  41373. * @param scene The scene to load into
  41374. * @param data The data to import
  41375. * @param rootUrl The root url for scene and resources
  41376. * @param onProgress The callback when the load progresses
  41377. * @param fileName Defines the name of the file to load
  41378. * @returns Nothing
  41379. */
  41380. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41381. /**
  41382. * The callback that returns true if the data can be directly loaded.
  41383. */
  41384. canDirectLoad?: (data: string) => boolean;
  41385. /**
  41386. * The callback that allows custom handling of the root url based on the response url.
  41387. */
  41388. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41389. /**
  41390. * Load into an asset container.
  41391. * @param scene The scene to load into
  41392. * @param data The data to import
  41393. * @param rootUrl The root url for scene and resources
  41394. * @param onProgress The callback when the load progresses
  41395. * @param fileName Defines the name of the file to load
  41396. * @returns The loaded asset container
  41397. */
  41398. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41399. }
  41400. /**
  41401. * Class used to load scene from various file formats using registered plugins
  41402. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41403. */
  41404. export class SceneLoader {
  41405. /**
  41406. * No logging while loading
  41407. */
  41408. static readonly NO_LOGGING: number;
  41409. /**
  41410. * Minimal logging while loading
  41411. */
  41412. static readonly MINIMAL_LOGGING: number;
  41413. /**
  41414. * Summary logging while loading
  41415. */
  41416. static readonly SUMMARY_LOGGING: number;
  41417. /**
  41418. * Detailled logging while loading
  41419. */
  41420. static readonly DETAILED_LOGGING: number;
  41421. /**
  41422. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41423. */
  41424. static ForceFullSceneLoadingForIncremental: boolean;
  41425. /**
  41426. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41427. */
  41428. static ShowLoadingScreen: boolean;
  41429. /**
  41430. * Defines the current logging level (while loading the scene)
  41431. * @ignorenaming
  41432. */
  41433. static loggingLevel: number;
  41434. /**
  41435. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41436. */
  41437. static CleanBoneMatrixWeights: boolean;
  41438. /**
  41439. * Event raised when a plugin is used to load a scene
  41440. */
  41441. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41442. private static _registeredPlugins;
  41443. private static _getDefaultPlugin;
  41444. private static _getPluginForExtension;
  41445. private static _getPluginForDirectLoad;
  41446. private static _getPluginForFilename;
  41447. private static _getDirectLoad;
  41448. private static _loadData;
  41449. private static _getFileInfo;
  41450. /**
  41451. * Gets a plugin that can load the given extension
  41452. * @param extension defines the extension to load
  41453. * @returns a plugin or null if none works
  41454. */
  41455. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41456. /**
  41457. * Gets a boolean indicating that the given extension can be loaded
  41458. * @param extension defines the extension to load
  41459. * @returns true if the extension is supported
  41460. */
  41461. static IsPluginForExtensionAvailable(extension: string): boolean;
  41462. /**
  41463. * Adds a new plugin to the list of registered plugins
  41464. * @param plugin defines the plugin to add
  41465. */
  41466. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41467. /**
  41468. * Import meshes into a scene
  41469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41470. * @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)
  41471. * @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)
  41472. * @param scene the instance of BABYLON.Scene to append to
  41473. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41474. * @param onProgress a callback with a progress event for each file being loaded
  41475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41476. * @param pluginExtension the extension used to determine the plugin
  41477. * @returns The loaded plugin
  41478. */
  41479. 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>;
  41480. /**
  41481. * Import meshes into a scene
  41482. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41483. * @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)
  41484. * @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)
  41485. * @param scene the instance of BABYLON.Scene to append to
  41486. * @param onProgress a callback with a progress event for each file being loaded
  41487. * @param pluginExtension the extension used to determine the plugin
  41488. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41489. */
  41490. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41491. meshes: AbstractMesh[];
  41492. particleSystems: IParticleSystem[];
  41493. skeletons: Skeleton[];
  41494. animationGroups: AnimationGroup[];
  41495. }>;
  41496. /**
  41497. * Load a scene
  41498. * @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)
  41499. * @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)
  41500. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41501. * @param onSuccess a callback with the scene when import succeeds
  41502. * @param onProgress a callback with a progress event for each file being loaded
  41503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41504. * @param pluginExtension the extension used to determine the plugin
  41505. * @returns The loaded plugin
  41506. */
  41507. 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>;
  41508. /**
  41509. * Load a scene
  41510. * @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)
  41511. * @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)
  41512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41513. * @param onProgress a callback with a progress event for each file being loaded
  41514. * @param pluginExtension the extension used to determine the plugin
  41515. * @returns The loaded scene
  41516. */
  41517. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41518. /**
  41519. * Append a scene
  41520. * @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)
  41521. * @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)
  41522. * @param scene is the instance of BABYLON.Scene to append to
  41523. * @param onSuccess a callback with the scene when import succeeds
  41524. * @param onProgress a callback with a progress event for each file being loaded
  41525. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41526. * @param pluginExtension the extension used to determine the plugin
  41527. * @returns The loaded plugin
  41528. */
  41529. 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>;
  41530. /**
  41531. * Append a scene
  41532. * @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)
  41533. * @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)
  41534. * @param scene is the instance of BABYLON.Scene to append to
  41535. * @param onProgress a callback with a progress event for each file being loaded
  41536. * @param pluginExtension the extension used to determine the plugin
  41537. * @returns The given scene
  41538. */
  41539. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41540. /**
  41541. * Load a scene into an asset container
  41542. * @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)
  41543. * @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)
  41544. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41545. * @param onSuccess a callback with the scene when import succeeds
  41546. * @param onProgress a callback with a progress event for each file being loaded
  41547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41548. * @param pluginExtension the extension used to determine the plugin
  41549. * @returns The loaded plugin
  41550. */
  41551. 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>;
  41552. /**
  41553. * Load a scene into an asset container
  41554. * @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)
  41555. * @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)
  41556. * @param scene is the instance of Scene to append to
  41557. * @param onProgress a callback with a progress event for each file being loaded
  41558. * @param pluginExtension the extension used to determine the plugin
  41559. * @returns The loaded asset container
  41560. */
  41561. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41562. }
  41563. }
  41564. declare module BABYLON {
  41565. /**
  41566. * Generic Controller
  41567. */
  41568. export class GenericController extends WebVRController {
  41569. /**
  41570. * Base Url for the controller model.
  41571. */
  41572. static readonly MODEL_BASE_URL: string;
  41573. /**
  41574. * File name for the controller model.
  41575. */
  41576. static readonly MODEL_FILENAME: string;
  41577. /**
  41578. * Creates a new GenericController from a gamepad
  41579. * @param vrGamepad the gamepad that the controller should be created from
  41580. */
  41581. constructor(vrGamepad: any);
  41582. /**
  41583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41584. * @param scene scene in which to add meshes
  41585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41586. */
  41587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41588. /**
  41589. * Called once for each button that changed state since the last frame
  41590. * @param buttonIdx Which button index changed
  41591. * @param state New state of the button
  41592. * @param changes Which properties on the state changed since last frame
  41593. */
  41594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41595. }
  41596. }
  41597. declare module BABYLON {
  41598. /**
  41599. * Defines the WindowsMotionController object that the state of the windows motion controller
  41600. */
  41601. export class WindowsMotionController extends WebVRController {
  41602. /**
  41603. * The base url used to load the left and right controller models
  41604. */
  41605. static MODEL_BASE_URL: string;
  41606. /**
  41607. * The name of the left controller model file
  41608. */
  41609. static MODEL_LEFT_FILENAME: string;
  41610. /**
  41611. * The name of the right controller model file
  41612. */
  41613. static MODEL_RIGHT_FILENAME: string;
  41614. /**
  41615. * The controller name prefix for this controller type
  41616. */
  41617. static readonly GAMEPAD_ID_PREFIX: string;
  41618. /**
  41619. * The controller id pattern for this controller type
  41620. */
  41621. private static readonly GAMEPAD_ID_PATTERN;
  41622. private _loadedMeshInfo;
  41623. private readonly _mapping;
  41624. /**
  41625. * Fired when the trackpad on this controller is clicked
  41626. */
  41627. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41628. /**
  41629. * Fired when the trackpad on this controller is modified
  41630. */
  41631. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41632. /**
  41633. * The current x and y values of this controller's trackpad
  41634. */
  41635. trackpad: StickValues;
  41636. /**
  41637. * Creates a new WindowsMotionController from a gamepad
  41638. * @param vrGamepad the gamepad that the controller should be created from
  41639. */
  41640. constructor(vrGamepad: any);
  41641. /**
  41642. * Fired when the trigger on this controller is modified
  41643. */
  41644. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41645. /**
  41646. * Fired when the menu button on this controller is modified
  41647. */
  41648. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41649. /**
  41650. * Fired when the grip button on this controller is modified
  41651. */
  41652. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41653. /**
  41654. * Fired when the thumbstick button on this controller is modified
  41655. */
  41656. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41657. /**
  41658. * Fired when the touchpad button on this controller is modified
  41659. */
  41660. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41661. /**
  41662. * Fired when the touchpad values on this controller are modified
  41663. */
  41664. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41665. private _updateTrackpad;
  41666. /**
  41667. * Called once per frame by the engine.
  41668. */
  41669. update(): void;
  41670. /**
  41671. * Called once for each button that changed state since the last frame
  41672. * @param buttonIdx Which button index changed
  41673. * @param state New state of the button
  41674. * @param changes Which properties on the state changed since last frame
  41675. */
  41676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41677. /**
  41678. * Moves the buttons on the controller mesh based on their current state
  41679. * @param buttonName the name of the button to move
  41680. * @param buttonValue the value of the button which determines the buttons new position
  41681. */
  41682. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41683. /**
  41684. * Moves the axis on the controller mesh based on its current state
  41685. * @param axis the index of the axis
  41686. * @param axisValue the value of the axis which determines the meshes new position
  41687. * @hidden
  41688. */
  41689. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41690. /**
  41691. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41692. * @param scene scene in which to add meshes
  41693. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41694. */
  41695. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41696. /**
  41697. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41698. * can be transformed by button presses and axes values, based on this._mapping.
  41699. *
  41700. * @param scene scene in which the meshes exist
  41701. * @param meshes list of meshes that make up the controller model to process
  41702. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41703. */
  41704. private processModel;
  41705. private createMeshInfo;
  41706. /**
  41707. * Gets the ray of the controller in the direction the controller is pointing
  41708. * @param length the length the resulting ray should be
  41709. * @returns a ray in the direction the controller is pointing
  41710. */
  41711. getForwardRay(length?: number): Ray;
  41712. /**
  41713. * Disposes of the controller
  41714. */
  41715. dispose(): void;
  41716. }
  41717. }
  41718. declare module BABYLON {
  41719. /**
  41720. * Oculus Touch Controller
  41721. */
  41722. export class OculusTouchController extends WebVRController {
  41723. /**
  41724. * Base Url for the controller model.
  41725. */
  41726. static MODEL_BASE_URL: string;
  41727. /**
  41728. * File name for the left controller model.
  41729. */
  41730. static MODEL_LEFT_FILENAME: string;
  41731. /**
  41732. * File name for the right controller model.
  41733. */
  41734. static MODEL_RIGHT_FILENAME: string;
  41735. /**
  41736. * Base Url for the Quest controller model.
  41737. */
  41738. static QUEST_MODEL_BASE_URL: string;
  41739. /**
  41740. * @hidden
  41741. * If the controllers are running on a device that needs the updated Quest controller models
  41742. */
  41743. static _IsQuest: boolean;
  41744. /**
  41745. * Fired when the secondary trigger on this controller is modified
  41746. */
  41747. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41748. /**
  41749. * Fired when the thumb rest on this controller is modified
  41750. */
  41751. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41752. /**
  41753. * Creates a new OculusTouchController from a gamepad
  41754. * @param vrGamepad the gamepad that the controller should be created from
  41755. */
  41756. constructor(vrGamepad: any);
  41757. /**
  41758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41759. * @param scene scene in which to add meshes
  41760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41761. */
  41762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41763. /**
  41764. * Fired when the A button on this controller is modified
  41765. */
  41766. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41767. /**
  41768. * Fired when the B button on this controller is modified
  41769. */
  41770. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41771. /**
  41772. * Fired when the X button on this controller is modified
  41773. */
  41774. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41775. /**
  41776. * Fired when the Y button on this controller is modified
  41777. */
  41778. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41779. /**
  41780. * Called once for each button that changed state since the last frame
  41781. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41782. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41783. * 2) secondary trigger (same)
  41784. * 3) A (right) X (left), touch, pressed = value
  41785. * 4) B / Y
  41786. * 5) thumb rest
  41787. * @param buttonIdx Which button index changed
  41788. * @param state New state of the button
  41789. * @param changes Which properties on the state changed since last frame
  41790. */
  41791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41792. }
  41793. }
  41794. declare module BABYLON {
  41795. /**
  41796. * Vive Controller
  41797. */
  41798. export class ViveController extends WebVRController {
  41799. /**
  41800. * Base Url for the controller model.
  41801. */
  41802. static MODEL_BASE_URL: string;
  41803. /**
  41804. * File name for the controller model.
  41805. */
  41806. static MODEL_FILENAME: string;
  41807. /**
  41808. * Creates a new ViveController from a gamepad
  41809. * @param vrGamepad the gamepad that the controller should be created from
  41810. */
  41811. constructor(vrGamepad: any);
  41812. /**
  41813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41814. * @param scene scene in which to add meshes
  41815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41816. */
  41817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41818. /**
  41819. * Fired when the left button on this controller is modified
  41820. */
  41821. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41822. /**
  41823. * Fired when the right button on this controller is modified
  41824. */
  41825. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41826. /**
  41827. * Fired when the menu button on this controller is modified
  41828. */
  41829. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41830. /**
  41831. * Called once for each button that changed state since the last frame
  41832. * Vive mapping:
  41833. * 0: touchpad
  41834. * 1: trigger
  41835. * 2: left AND right buttons
  41836. * 3: menu button
  41837. * @param buttonIdx Which button index changed
  41838. * @param state New state of the button
  41839. * @param changes Which properties on the state changed since last frame
  41840. */
  41841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41842. }
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41847. */
  41848. export class WebXRControllerModelLoader {
  41849. /**
  41850. * Creates the WebXRControllerModelLoader
  41851. * @param input xr input that creates the controllers
  41852. */
  41853. constructor(input: WebXRInput);
  41854. }
  41855. }
  41856. declare module BABYLON {
  41857. /**
  41858. * Contains an array of blocks representing the octree
  41859. */
  41860. export interface IOctreeContainer<T> {
  41861. /**
  41862. * Blocks within the octree
  41863. */
  41864. blocks: Array<OctreeBlock<T>>;
  41865. }
  41866. /**
  41867. * Class used to store a cell in an octree
  41868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41869. */
  41870. export class OctreeBlock<T> {
  41871. /**
  41872. * Gets the content of the current block
  41873. */
  41874. entries: T[];
  41875. /**
  41876. * Gets the list of block children
  41877. */
  41878. blocks: Array<OctreeBlock<T>>;
  41879. private _depth;
  41880. private _maxDepth;
  41881. private _capacity;
  41882. private _minPoint;
  41883. private _maxPoint;
  41884. private _boundingVectors;
  41885. private _creationFunc;
  41886. /**
  41887. * Creates a new block
  41888. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41889. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41890. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41891. * @param depth defines the current depth of this block in the octree
  41892. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41893. * @param creationFunc defines a callback to call when an element is added to the block
  41894. */
  41895. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41896. /**
  41897. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41898. */
  41899. readonly capacity: number;
  41900. /**
  41901. * Gets the minimum vector (in world space) of the block's bounding box
  41902. */
  41903. readonly minPoint: Vector3;
  41904. /**
  41905. * Gets the maximum vector (in world space) of the block's bounding box
  41906. */
  41907. readonly maxPoint: Vector3;
  41908. /**
  41909. * Add a new element to this block
  41910. * @param entry defines the element to add
  41911. */
  41912. addEntry(entry: T): void;
  41913. /**
  41914. * Remove an element from this block
  41915. * @param entry defines the element to remove
  41916. */
  41917. removeEntry(entry: T): void;
  41918. /**
  41919. * Add an array of elements to this block
  41920. * @param entries defines the array of elements to add
  41921. */
  41922. addEntries(entries: T[]): void;
  41923. /**
  41924. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41925. * @param frustumPlanes defines the frustum planes to test
  41926. * @param selection defines the array to store current content if selection is positive
  41927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41928. */
  41929. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41930. /**
  41931. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41932. * @param sphereCenter defines the bounding sphere center
  41933. * @param sphereRadius defines the bounding sphere radius
  41934. * @param selection defines the array to store current content if selection is positive
  41935. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41936. */
  41937. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41938. /**
  41939. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41940. * @param ray defines the ray to test with
  41941. * @param selection defines the array to store current content if selection is positive
  41942. */
  41943. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41944. /**
  41945. * Subdivide the content into child blocks (this block will then be empty)
  41946. */
  41947. createInnerBlocks(): void;
  41948. /**
  41949. * @hidden
  41950. */
  41951. 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;
  41952. }
  41953. }
  41954. declare module BABYLON {
  41955. /**
  41956. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41958. */
  41959. export class Octree<T> {
  41960. /** 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.) */
  41961. maxDepth: number;
  41962. /**
  41963. * Blocks within the octree containing objects
  41964. */
  41965. blocks: Array<OctreeBlock<T>>;
  41966. /**
  41967. * Content stored in the octree
  41968. */
  41969. dynamicContent: T[];
  41970. private _maxBlockCapacity;
  41971. private _selectionContent;
  41972. private _creationFunc;
  41973. /**
  41974. * Creates a octree
  41975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41976. * @param creationFunc function to be used to instatiate the octree
  41977. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41978. * @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.)
  41979. */
  41980. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41981. /** 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.) */
  41982. maxDepth?: number);
  41983. /**
  41984. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41985. * @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);
  41986. * @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);
  41987. * @param entries meshes to be added to the octree blocks
  41988. */
  41989. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41990. /**
  41991. * Adds a mesh to the octree
  41992. * @param entry Mesh to add to the octree
  41993. */
  41994. addMesh(entry: T): void;
  41995. /**
  41996. * Remove an element from the octree
  41997. * @param entry defines the element to remove
  41998. */
  41999. removeMesh(entry: T): void;
  42000. /**
  42001. * Selects an array of meshes within the frustum
  42002. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42003. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42004. * @returns array of meshes within the frustum
  42005. */
  42006. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42007. /**
  42008. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42009. * @param sphereCenter defines the bounding sphere center
  42010. * @param sphereRadius defines the bounding sphere radius
  42011. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42012. * @returns an array of objects that intersect the sphere
  42013. */
  42014. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42015. /**
  42016. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42017. * @param ray defines the ray to test with
  42018. * @returns array of intersected objects
  42019. */
  42020. intersectsRay(ray: Ray): SmartArray<T>;
  42021. /**
  42022. * Adds a mesh into the octree block if it intersects the block
  42023. */
  42024. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42025. /**
  42026. * Adds a submesh into the octree block if it intersects the block
  42027. */
  42028. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42029. }
  42030. }
  42031. declare module BABYLON {
  42032. interface Scene {
  42033. /**
  42034. * @hidden
  42035. * Backing Filed
  42036. */
  42037. _selectionOctree: Octree<AbstractMesh>;
  42038. /**
  42039. * Gets the octree used to boost mesh selection (picking)
  42040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42041. */
  42042. selectionOctree: Octree<AbstractMesh>;
  42043. /**
  42044. * Creates or updates the octree used to boost selection (picking)
  42045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42046. * @param maxCapacity defines the maximum capacity per leaf
  42047. * @param maxDepth defines the maximum depth of the octree
  42048. * @returns an octree of AbstractMesh
  42049. */
  42050. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42051. }
  42052. interface AbstractMesh {
  42053. /**
  42054. * @hidden
  42055. * Backing Field
  42056. */
  42057. _submeshesOctree: Octree<SubMesh>;
  42058. /**
  42059. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42060. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42061. * @param maxCapacity defines the maximum size of each block (64 by default)
  42062. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42063. * @returns the new octree
  42064. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42066. */
  42067. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42068. }
  42069. /**
  42070. * Defines the octree scene component responsible to manage any octrees
  42071. * in a given scene.
  42072. */
  42073. export class OctreeSceneComponent {
  42074. /**
  42075. * The component name help to identify the component in the list of scene components.
  42076. */
  42077. readonly name: string;
  42078. /**
  42079. * The scene the component belongs to.
  42080. */
  42081. scene: Scene;
  42082. /**
  42083. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42084. */
  42085. readonly checksIsEnabled: boolean;
  42086. /**
  42087. * Creates a new instance of the component for the given scene
  42088. * @param scene Defines the scene to register the component in
  42089. */
  42090. constructor(scene: Scene);
  42091. /**
  42092. * Registers the component in a given scene
  42093. */
  42094. register(): void;
  42095. /**
  42096. * Return the list of active meshes
  42097. * @returns the list of active meshes
  42098. */
  42099. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42100. /**
  42101. * Return the list of active sub meshes
  42102. * @param mesh The mesh to get the candidates sub meshes from
  42103. * @returns the list of active sub meshes
  42104. */
  42105. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42106. private _tempRay;
  42107. /**
  42108. * Return the list of sub meshes intersecting with a given local ray
  42109. * @param mesh defines the mesh to find the submesh for
  42110. * @param localRay defines the ray in local space
  42111. * @returns the list of intersecting sub meshes
  42112. */
  42113. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42114. /**
  42115. * Return the list of sub meshes colliding with a collider
  42116. * @param mesh defines the mesh to find the submesh for
  42117. * @param collider defines the collider to evaluate the collision against
  42118. * @returns the list of colliding sub meshes
  42119. */
  42120. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42121. /**
  42122. * Rebuilds the elements related to this component in case of
  42123. * context lost for instance.
  42124. */
  42125. rebuild(): void;
  42126. /**
  42127. * Disposes the component and the associated ressources.
  42128. */
  42129. dispose(): void;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Renders a layer on top of an existing scene
  42135. */
  42136. export class UtilityLayerRenderer implements IDisposable {
  42137. /** the original scene that will be rendered on top of */
  42138. originalScene: Scene;
  42139. private _pointerCaptures;
  42140. private _lastPointerEvents;
  42141. private static _DefaultUtilityLayer;
  42142. private static _DefaultKeepDepthUtilityLayer;
  42143. private _sharedGizmoLight;
  42144. private _renderCamera;
  42145. /**
  42146. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42147. * @returns the camera that is used when rendering the utility layer
  42148. */
  42149. getRenderCamera(): Nullable<Camera>;
  42150. /**
  42151. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42152. * @param cam the camera that should be used when rendering the utility layer
  42153. */
  42154. setRenderCamera(cam: Nullable<Camera>): void;
  42155. /**
  42156. * @hidden
  42157. * Light which used by gizmos to get light shading
  42158. */
  42159. _getSharedGizmoLight(): HemisphericLight;
  42160. /**
  42161. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42162. */
  42163. pickUtilitySceneFirst: boolean;
  42164. /**
  42165. * 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)
  42166. */
  42167. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42168. /**
  42169. * 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)
  42170. */
  42171. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42172. /**
  42173. * The scene that is rendered on top of the original scene
  42174. */
  42175. utilityLayerScene: Scene;
  42176. /**
  42177. * If the utility layer should automatically be rendered on top of existing scene
  42178. */
  42179. shouldRender: boolean;
  42180. /**
  42181. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42182. */
  42183. onlyCheckPointerDownEvents: boolean;
  42184. /**
  42185. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42186. */
  42187. processAllEvents: boolean;
  42188. /**
  42189. * Observable raised when the pointer move from the utility layer scene to the main scene
  42190. */
  42191. onPointerOutObservable: Observable<number>;
  42192. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42193. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42194. private _afterRenderObserver;
  42195. private _sceneDisposeObserver;
  42196. private _originalPointerObserver;
  42197. /**
  42198. * Instantiates a UtilityLayerRenderer
  42199. * @param originalScene the original scene that will be rendered on top of
  42200. * @param handleEvents boolean indicating if the utility layer should handle events
  42201. */
  42202. constructor(
  42203. /** the original scene that will be rendered on top of */
  42204. originalScene: Scene, handleEvents?: boolean);
  42205. private _notifyObservers;
  42206. /**
  42207. * Renders the utility layers scene on top of the original scene
  42208. */
  42209. render(): void;
  42210. /**
  42211. * Disposes of the renderer
  42212. */
  42213. dispose(): void;
  42214. private _updateCamera;
  42215. }
  42216. }
  42217. declare module BABYLON {
  42218. /**
  42219. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42220. */
  42221. export class Gizmo implements IDisposable {
  42222. /** The utility layer the gizmo will be added to */
  42223. gizmoLayer: UtilityLayerRenderer;
  42224. /**
  42225. * The root mesh of the gizmo
  42226. */
  42227. _rootMesh: Mesh;
  42228. private _attachedMesh;
  42229. /**
  42230. * Ratio for the scale of the gizmo (Default: 1)
  42231. */
  42232. scaleRatio: number;
  42233. /**
  42234. * If a custom mesh has been set (Default: false)
  42235. */
  42236. protected _customMeshSet: boolean;
  42237. /**
  42238. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42239. * * When set, interactions will be enabled
  42240. */
  42241. attachedMesh: Nullable<AbstractMesh>;
  42242. /**
  42243. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42244. * @param mesh The mesh to replace the default mesh of the gizmo
  42245. */
  42246. setCustomMesh(mesh: Mesh): void;
  42247. /**
  42248. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42249. */
  42250. updateGizmoRotationToMatchAttachedMesh: boolean;
  42251. /**
  42252. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42253. */
  42254. updateGizmoPositionToMatchAttachedMesh: boolean;
  42255. /**
  42256. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42257. */
  42258. updateScale: boolean;
  42259. protected _interactionsEnabled: boolean;
  42260. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42261. private _beforeRenderObserver;
  42262. private _tempVector;
  42263. /**
  42264. * Creates a gizmo
  42265. * @param gizmoLayer The utility layer the gizmo will be added to
  42266. */
  42267. constructor(
  42268. /** The utility layer the gizmo will be added to */
  42269. gizmoLayer?: UtilityLayerRenderer);
  42270. /**
  42271. * Updates the gizmo to match the attached mesh's position/rotation
  42272. */
  42273. protected _update(): void;
  42274. /**
  42275. * Disposes of the gizmo
  42276. */
  42277. dispose(): void;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Single plane drag gizmo
  42283. */
  42284. export class PlaneDragGizmo extends Gizmo {
  42285. /**
  42286. * Drag behavior responsible for the gizmos dragging interactions
  42287. */
  42288. dragBehavior: PointerDragBehavior;
  42289. private _pointerObserver;
  42290. /**
  42291. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42292. */
  42293. snapDistance: number;
  42294. /**
  42295. * Event that fires each time the gizmo snaps to a new location.
  42296. * * snapDistance is the the change in distance
  42297. */
  42298. onSnapObservable: Observable<{
  42299. snapDistance: number;
  42300. }>;
  42301. private _plane;
  42302. private _coloredMaterial;
  42303. private _hoverMaterial;
  42304. private _isEnabled;
  42305. private _parent;
  42306. /** @hidden */
  42307. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42308. /** @hidden */
  42309. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42310. /**
  42311. * Creates a PlaneDragGizmo
  42312. * @param gizmoLayer The utility layer the gizmo will be added to
  42313. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42314. * @param color The color of the gizmo
  42315. */
  42316. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42318. /**
  42319. * If the gizmo is enabled
  42320. */
  42321. isEnabled: boolean;
  42322. /**
  42323. * Disposes of the gizmo
  42324. */
  42325. dispose(): void;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Gizmo that enables dragging a mesh along 3 axis
  42331. */
  42332. export class PositionGizmo extends Gizmo {
  42333. /**
  42334. * Internal gizmo used for interactions on the x axis
  42335. */
  42336. xGizmo: AxisDragGizmo;
  42337. /**
  42338. * Internal gizmo used for interactions on the y axis
  42339. */
  42340. yGizmo: AxisDragGizmo;
  42341. /**
  42342. * Internal gizmo used for interactions on the z axis
  42343. */
  42344. zGizmo: AxisDragGizmo;
  42345. /**
  42346. * Internal gizmo used for interactions on the yz plane
  42347. */
  42348. xPlaneGizmo: PlaneDragGizmo;
  42349. /**
  42350. * Internal gizmo used for interactions on the xz plane
  42351. */
  42352. yPlaneGizmo: PlaneDragGizmo;
  42353. /**
  42354. * Internal gizmo used for interactions on the xy plane
  42355. */
  42356. zPlaneGizmo: PlaneDragGizmo;
  42357. /**
  42358. * private variables
  42359. */
  42360. private _meshAttached;
  42361. private _updateGizmoRotationToMatchAttachedMesh;
  42362. private _snapDistance;
  42363. private _scaleRatio;
  42364. /** Fires an event when any of it's sub gizmos are dragged */
  42365. onDragStartObservable: Observable<unknown>;
  42366. /** Fires an event when any of it's sub gizmos are released from dragging */
  42367. onDragEndObservable: Observable<unknown>;
  42368. /**
  42369. * If set to true, planar drag is enabled
  42370. */
  42371. private _planarGizmoEnabled;
  42372. attachedMesh: Nullable<AbstractMesh>;
  42373. /**
  42374. * Creates a PositionGizmo
  42375. * @param gizmoLayer The utility layer the gizmo will be added to
  42376. */
  42377. constructor(gizmoLayer?: UtilityLayerRenderer);
  42378. /**
  42379. * If the planar drag gizmo is enabled
  42380. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42381. */
  42382. planarGizmoEnabled: boolean;
  42383. updateGizmoRotationToMatchAttachedMesh: boolean;
  42384. /**
  42385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42386. */
  42387. snapDistance: number;
  42388. /**
  42389. * Ratio for the scale of the gizmo (Default: 1)
  42390. */
  42391. scaleRatio: number;
  42392. /**
  42393. * Disposes of the gizmo
  42394. */
  42395. dispose(): void;
  42396. /**
  42397. * CustomMeshes are not supported by this gizmo
  42398. * @param mesh The mesh to replace the default mesh of the gizmo
  42399. */
  42400. setCustomMesh(mesh: Mesh): void;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * Single axis drag gizmo
  42406. */
  42407. export class AxisDragGizmo extends Gizmo {
  42408. /**
  42409. * Drag behavior responsible for the gizmos dragging interactions
  42410. */
  42411. dragBehavior: PointerDragBehavior;
  42412. private _pointerObserver;
  42413. /**
  42414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42415. */
  42416. snapDistance: number;
  42417. /**
  42418. * Event that fires each time the gizmo snaps to a new location.
  42419. * * snapDistance is the the change in distance
  42420. */
  42421. onSnapObservable: Observable<{
  42422. snapDistance: number;
  42423. }>;
  42424. private _isEnabled;
  42425. private _parent;
  42426. private _arrow;
  42427. private _coloredMaterial;
  42428. private _hoverMaterial;
  42429. /** @hidden */
  42430. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42431. /** @hidden */
  42432. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42433. /**
  42434. * Creates an AxisDragGizmo
  42435. * @param gizmoLayer The utility layer the gizmo will be added to
  42436. * @param dragAxis The axis which the gizmo will be able to drag on
  42437. * @param color The color of the gizmo
  42438. */
  42439. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42441. /**
  42442. * If the gizmo is enabled
  42443. */
  42444. isEnabled: boolean;
  42445. /**
  42446. * Disposes of the gizmo
  42447. */
  42448. dispose(): void;
  42449. }
  42450. }
  42451. declare module BABYLON.Debug {
  42452. /**
  42453. * The Axes viewer will show 3 axes in a specific point in space
  42454. */
  42455. export class AxesViewer {
  42456. private _xAxis;
  42457. private _yAxis;
  42458. private _zAxis;
  42459. private _scaleLinesFactor;
  42460. private _instanced;
  42461. /**
  42462. * Gets the hosting scene
  42463. */
  42464. scene: Scene;
  42465. /**
  42466. * Gets or sets a number used to scale line length
  42467. */
  42468. scaleLines: number;
  42469. /** Gets the node hierarchy used to render x-axis */
  42470. readonly xAxis: TransformNode;
  42471. /** Gets the node hierarchy used to render y-axis */
  42472. readonly yAxis: TransformNode;
  42473. /** Gets the node hierarchy used to render z-axis */
  42474. readonly zAxis: TransformNode;
  42475. /**
  42476. * Creates a new AxesViewer
  42477. * @param scene defines the hosting scene
  42478. * @param scaleLines defines a number used to scale line length (1 by default)
  42479. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42480. * @param xAxis defines the node hierarchy used to render the x-axis
  42481. * @param yAxis defines the node hierarchy used to render the y-axis
  42482. * @param zAxis defines the node hierarchy used to render the z-axis
  42483. */
  42484. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42485. /**
  42486. * Force the viewer to update
  42487. * @param position defines the position of the viewer
  42488. * @param xaxis defines the x axis of the viewer
  42489. * @param yaxis defines the y axis of the viewer
  42490. * @param zaxis defines the z axis of the viewer
  42491. */
  42492. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42493. /**
  42494. * Creates an instance of this axes viewer.
  42495. * @returns a new axes viewer with instanced meshes
  42496. */
  42497. createInstance(): AxesViewer;
  42498. /** Releases resources */
  42499. dispose(): void;
  42500. private static _SetRenderingGroupId;
  42501. }
  42502. }
  42503. declare module BABYLON.Debug {
  42504. /**
  42505. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42506. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42507. */
  42508. export class BoneAxesViewer extends AxesViewer {
  42509. /**
  42510. * Gets or sets the target mesh where to display the axes viewer
  42511. */
  42512. mesh: Nullable<Mesh>;
  42513. /**
  42514. * Gets or sets the target bone where to display the axes viewer
  42515. */
  42516. bone: Nullable<Bone>;
  42517. /** Gets current position */
  42518. pos: Vector3;
  42519. /** Gets direction of X axis */
  42520. xaxis: Vector3;
  42521. /** Gets direction of Y axis */
  42522. yaxis: Vector3;
  42523. /** Gets direction of Z axis */
  42524. zaxis: Vector3;
  42525. /**
  42526. * Creates a new BoneAxesViewer
  42527. * @param scene defines the hosting scene
  42528. * @param bone defines the target bone
  42529. * @param mesh defines the target mesh
  42530. * @param scaleLines defines a scaling factor for line length (1 by default)
  42531. */
  42532. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42533. /**
  42534. * Force the viewer to update
  42535. */
  42536. update(): void;
  42537. /** Releases resources */
  42538. dispose(): void;
  42539. }
  42540. }
  42541. declare module BABYLON {
  42542. /**
  42543. * Interface used to define scene explorer extensibility option
  42544. */
  42545. export interface IExplorerExtensibilityOption {
  42546. /**
  42547. * Define the option label
  42548. */
  42549. label: string;
  42550. /**
  42551. * Defines the action to execute on click
  42552. */
  42553. action: (entity: any) => void;
  42554. }
  42555. /**
  42556. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42557. */
  42558. export interface IExplorerExtensibilityGroup {
  42559. /**
  42560. * Defines a predicate to test if a given type mut be extended
  42561. */
  42562. predicate: (entity: any) => boolean;
  42563. /**
  42564. * Gets the list of options added to a type
  42565. */
  42566. entries: IExplorerExtensibilityOption[];
  42567. }
  42568. /**
  42569. * Interface used to define the options to use to create the Inspector
  42570. */
  42571. export interface IInspectorOptions {
  42572. /**
  42573. * Display in overlay mode (default: false)
  42574. */
  42575. overlay?: boolean;
  42576. /**
  42577. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42578. */
  42579. globalRoot?: HTMLElement;
  42580. /**
  42581. * Display the Scene explorer
  42582. */
  42583. showExplorer?: boolean;
  42584. /**
  42585. * Display the property inspector
  42586. */
  42587. showInspector?: boolean;
  42588. /**
  42589. * Display in embed mode (both panes on the right)
  42590. */
  42591. embedMode?: boolean;
  42592. /**
  42593. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42594. */
  42595. handleResize?: boolean;
  42596. /**
  42597. * Allow the panes to popup (default: true)
  42598. */
  42599. enablePopup?: boolean;
  42600. /**
  42601. * Allow the panes to be closed by users (default: true)
  42602. */
  42603. enableClose?: boolean;
  42604. /**
  42605. * Optional list of extensibility entries
  42606. */
  42607. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42608. /**
  42609. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42610. */
  42611. inspectorURL?: string;
  42612. }
  42613. interface Scene {
  42614. /**
  42615. * @hidden
  42616. * Backing field
  42617. */
  42618. _debugLayer: DebugLayer;
  42619. /**
  42620. * Gets the debug layer (aka Inspector) associated with the scene
  42621. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42622. */
  42623. debugLayer: DebugLayer;
  42624. }
  42625. /**
  42626. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42627. * what is happening in your scene
  42628. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42629. */
  42630. export class DebugLayer {
  42631. /**
  42632. * Define the url to get the inspector script from.
  42633. * By default it uses the babylonjs CDN.
  42634. * @ignoreNaming
  42635. */
  42636. static InspectorURL: string;
  42637. private _scene;
  42638. private BJSINSPECTOR;
  42639. private _onPropertyChangedObservable?;
  42640. /**
  42641. * Observable triggered when a property is changed through the inspector.
  42642. */
  42643. readonly onPropertyChangedObservable: any;
  42644. /**
  42645. * Instantiates a new debug layer.
  42646. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42647. * what is happening in your scene
  42648. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42649. * @param scene Defines the scene to inspect
  42650. */
  42651. constructor(scene: Scene);
  42652. /** Creates the inspector window. */
  42653. private _createInspector;
  42654. /**
  42655. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42656. * @param entity defines the entity to select
  42657. * @param lineContainerTitle defines the specific block to highlight
  42658. */
  42659. select(entity: any, lineContainerTitle?: string): void;
  42660. /** Get the inspector from bundle or global */
  42661. private _getGlobalInspector;
  42662. /**
  42663. * Get if the inspector is visible or not.
  42664. * @returns true if visible otherwise, false
  42665. */
  42666. isVisible(): boolean;
  42667. /**
  42668. * Hide the inspector and close its window.
  42669. */
  42670. hide(): void;
  42671. /**
  42672. * Launch the debugLayer.
  42673. * @param config Define the configuration of the inspector
  42674. * @return a promise fulfilled when the debug layer is visible
  42675. */
  42676. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42677. }
  42678. }
  42679. declare module BABYLON {
  42680. /**
  42681. * Class containing static functions to help procedurally build meshes
  42682. */
  42683. export class BoxBuilder {
  42684. /**
  42685. * Creates a box mesh
  42686. * * The parameter `size` sets the size (float) of each box side (default 1)
  42687. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42688. * * 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)
  42689. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42691. * * 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
  42692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42693. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42694. * @param name defines the name of the mesh
  42695. * @param options defines the options used to create the mesh
  42696. * @param scene defines the hosting scene
  42697. * @returns the box mesh
  42698. */
  42699. static CreateBox(name: string, options: {
  42700. size?: number;
  42701. width?: number;
  42702. height?: number;
  42703. depth?: number;
  42704. faceUV?: Vector4[];
  42705. faceColors?: Color4[];
  42706. sideOrientation?: number;
  42707. frontUVs?: Vector4;
  42708. backUVs?: Vector4;
  42709. wrap?: boolean;
  42710. topBaseAt?: number;
  42711. bottomBaseAt?: number;
  42712. updatable?: boolean;
  42713. }, scene?: Nullable<Scene>): Mesh;
  42714. }
  42715. }
  42716. declare module BABYLON {
  42717. /**
  42718. * Class containing static functions to help procedurally build meshes
  42719. */
  42720. export class SphereBuilder {
  42721. /**
  42722. * Creates a sphere mesh
  42723. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42724. * * 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`)
  42725. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42726. * * 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
  42727. * * 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)
  42728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42729. * * 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
  42730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42731. * @param name defines the name of the mesh
  42732. * @param options defines the options used to create the mesh
  42733. * @param scene defines the hosting scene
  42734. * @returns the sphere mesh
  42735. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42736. */
  42737. static CreateSphere(name: string, options: {
  42738. segments?: number;
  42739. diameter?: number;
  42740. diameterX?: number;
  42741. diameterY?: number;
  42742. diameterZ?: number;
  42743. arc?: number;
  42744. slice?: number;
  42745. sideOrientation?: number;
  42746. frontUVs?: Vector4;
  42747. backUVs?: Vector4;
  42748. updatable?: boolean;
  42749. }, scene: any): Mesh;
  42750. }
  42751. }
  42752. declare module BABYLON.Debug {
  42753. /**
  42754. * Used to show the physics impostor around the specific mesh
  42755. */
  42756. export class PhysicsViewer {
  42757. /** @hidden */
  42758. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42759. /** @hidden */
  42760. protected _meshes: Array<Nullable<AbstractMesh>>;
  42761. /** @hidden */
  42762. protected _scene: Nullable<Scene>;
  42763. /** @hidden */
  42764. protected _numMeshes: number;
  42765. /** @hidden */
  42766. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42767. private _renderFunction;
  42768. private _utilityLayer;
  42769. private _debugBoxMesh;
  42770. private _debugSphereMesh;
  42771. private _debugCylinderMesh;
  42772. private _debugMaterial;
  42773. private _debugMeshMeshes;
  42774. /**
  42775. * Creates a new PhysicsViewer
  42776. * @param scene defines the hosting scene
  42777. */
  42778. constructor(scene: Scene);
  42779. /** @hidden */
  42780. protected _updateDebugMeshes(): void;
  42781. /**
  42782. * Renders a specified physic impostor
  42783. * @param impostor defines the impostor to render
  42784. * @param targetMesh defines the mesh represented by the impostor
  42785. * @returns the new debug mesh used to render the impostor
  42786. */
  42787. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42788. /**
  42789. * Hides a specified physic impostor
  42790. * @param impostor defines the impostor to hide
  42791. */
  42792. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42793. private _getDebugMaterial;
  42794. private _getDebugBoxMesh;
  42795. private _getDebugSphereMesh;
  42796. private _getDebugCylinderMesh;
  42797. private _getDebugMeshMesh;
  42798. private _getDebugMesh;
  42799. /** Releases all resources */
  42800. dispose(): void;
  42801. }
  42802. }
  42803. declare module BABYLON {
  42804. /**
  42805. * Class containing static functions to help procedurally build meshes
  42806. */
  42807. export class LinesBuilder {
  42808. /**
  42809. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42810. * * 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
  42811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42812. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42813. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42814. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42815. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42816. * * 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
  42817. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42820. * @param name defines the name of the new line system
  42821. * @param options defines the options used to create the line system
  42822. * @param scene defines the hosting scene
  42823. * @returns a new line system mesh
  42824. */
  42825. static CreateLineSystem(name: string, options: {
  42826. lines: Vector3[][];
  42827. updatable?: boolean;
  42828. instance?: Nullable<LinesMesh>;
  42829. colors?: Nullable<Color4[][]>;
  42830. useVertexAlpha?: boolean;
  42831. }, scene: Nullable<Scene>): LinesMesh;
  42832. /**
  42833. * Creates a line mesh
  42834. * 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
  42835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42836. * * The parameter `points` is an array successive Vector3
  42837. * * 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
  42838. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42839. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42840. * * When updating an instance, remember that only point positions can change, not the number of points
  42841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42843. * @param name defines the name of the new line system
  42844. * @param options defines the options used to create the line system
  42845. * @param scene defines the hosting scene
  42846. * @returns a new line mesh
  42847. */
  42848. static CreateLines(name: string, options: {
  42849. points: Vector3[];
  42850. updatable?: boolean;
  42851. instance?: Nullable<LinesMesh>;
  42852. colors?: Color4[];
  42853. useVertexAlpha?: boolean;
  42854. }, scene?: Nullable<Scene>): LinesMesh;
  42855. /**
  42856. * Creates a dashed line mesh
  42857. * * 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
  42858. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42859. * * The parameter `points` is an array successive Vector3
  42860. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42861. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42862. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42863. * * 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
  42864. * * When updating an instance, remember that only point positions can change, not the number of points
  42865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42866. * @param name defines the name of the mesh
  42867. * @param options defines the options used to create the mesh
  42868. * @param scene defines the hosting scene
  42869. * @returns the dashed line mesh
  42870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42871. */
  42872. static CreateDashedLines(name: string, options: {
  42873. points: Vector3[];
  42874. dashSize?: number;
  42875. gapSize?: number;
  42876. dashNb?: number;
  42877. updatable?: boolean;
  42878. instance?: LinesMesh;
  42879. }, scene?: Nullable<Scene>): LinesMesh;
  42880. }
  42881. }
  42882. declare module BABYLON {
  42883. /**
  42884. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42885. * in order to better appreciate the issue one might have.
  42886. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42887. */
  42888. export class RayHelper {
  42889. /**
  42890. * Defines the ray we are currently tryin to visualize.
  42891. */
  42892. ray: Nullable<Ray>;
  42893. private _renderPoints;
  42894. private _renderLine;
  42895. private _renderFunction;
  42896. private _scene;
  42897. private _updateToMeshFunction;
  42898. private _attachedToMesh;
  42899. private _meshSpaceDirection;
  42900. private _meshSpaceOrigin;
  42901. /**
  42902. * Helper function to create a colored helper in a scene in one line.
  42903. * @param ray Defines the ray we are currently tryin to visualize
  42904. * @param scene Defines the scene the ray is used in
  42905. * @param color Defines the color we want to see the ray in
  42906. * @returns The newly created ray helper.
  42907. */
  42908. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42909. /**
  42910. * Instantiate a new ray helper.
  42911. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42912. * in order to better appreciate the issue one might have.
  42913. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42914. * @param ray Defines the ray we are currently tryin to visualize
  42915. */
  42916. constructor(ray: Ray);
  42917. /**
  42918. * Shows the ray we are willing to debug.
  42919. * @param scene Defines the scene the ray needs to be rendered in
  42920. * @param color Defines the color the ray needs to be rendered in
  42921. */
  42922. show(scene: Scene, color?: Color3): void;
  42923. /**
  42924. * Hides the ray we are debugging.
  42925. */
  42926. hide(): void;
  42927. private _render;
  42928. /**
  42929. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42930. * @param mesh Defines the mesh we want the helper attached to
  42931. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42932. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42933. * @param length Defines the length of the ray
  42934. */
  42935. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42936. /**
  42937. * Detach the ray helper from the mesh it has previously been attached to.
  42938. */
  42939. detachFromMesh(): void;
  42940. private _updateToMesh;
  42941. /**
  42942. * Dispose the helper and release its associated resources.
  42943. */
  42944. dispose(): void;
  42945. }
  42946. }
  42947. declare module BABYLON.Debug {
  42948. /**
  42949. * Class used to render a debug view of a given skeleton
  42950. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42951. */
  42952. export class SkeletonViewer {
  42953. /** defines the skeleton to render */
  42954. skeleton: Skeleton;
  42955. /** defines the mesh attached to the skeleton */
  42956. mesh: AbstractMesh;
  42957. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42958. autoUpdateBonesMatrices: boolean;
  42959. /** defines the rendering group id to use with the viewer */
  42960. renderingGroupId: number;
  42961. /** Gets or sets the color used to render the skeleton */
  42962. color: Color3;
  42963. private _scene;
  42964. private _debugLines;
  42965. private _debugMesh;
  42966. private _isEnabled;
  42967. private _renderFunction;
  42968. private _utilityLayer;
  42969. /**
  42970. * Returns the mesh used to render the bones
  42971. */
  42972. readonly debugMesh: Nullable<LinesMesh>;
  42973. /**
  42974. * Creates a new SkeletonViewer
  42975. * @param skeleton defines the skeleton to render
  42976. * @param mesh defines the mesh attached to the skeleton
  42977. * @param scene defines the hosting scene
  42978. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42979. * @param renderingGroupId defines the rendering group id to use with the viewer
  42980. */
  42981. constructor(
  42982. /** defines the skeleton to render */
  42983. skeleton: Skeleton,
  42984. /** defines the mesh attached to the skeleton */
  42985. mesh: AbstractMesh, scene: Scene,
  42986. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42987. autoUpdateBonesMatrices?: boolean,
  42988. /** defines the rendering group id to use with the viewer */
  42989. renderingGroupId?: number);
  42990. /** Gets or sets a boolean indicating if the viewer is enabled */
  42991. isEnabled: boolean;
  42992. private _getBonePosition;
  42993. private _getLinesForBonesWithLength;
  42994. private _getLinesForBonesNoLength;
  42995. /** Update the viewer to sync with current skeleton state */
  42996. update(): void;
  42997. /** Release associated resources */
  42998. dispose(): void;
  42999. }
  43000. }
  43001. declare module BABYLON {
  43002. /**
  43003. * Options to create the null engine
  43004. */
  43005. export class NullEngineOptions {
  43006. /**
  43007. * Render width (Default: 512)
  43008. */
  43009. renderWidth: number;
  43010. /**
  43011. * Render height (Default: 256)
  43012. */
  43013. renderHeight: number;
  43014. /**
  43015. * Texture size (Default: 512)
  43016. */
  43017. textureSize: number;
  43018. /**
  43019. * If delta time between frames should be constant
  43020. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43021. */
  43022. deterministicLockstep: boolean;
  43023. /**
  43024. * Maximum about of steps between frames (Default: 4)
  43025. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43026. */
  43027. lockstepMaxSteps: number;
  43028. }
  43029. /**
  43030. * The null engine class provides support for headless version of babylon.js.
  43031. * This can be used in server side scenario or for testing purposes
  43032. */
  43033. export class NullEngine extends Engine {
  43034. private _options;
  43035. /**
  43036. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43037. */
  43038. isDeterministicLockStep(): boolean;
  43039. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43040. getLockstepMaxSteps(): number;
  43041. /**
  43042. * Sets hardware scaling, used to save performance if needed
  43043. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43044. */
  43045. getHardwareScalingLevel(): number;
  43046. constructor(options?: NullEngineOptions);
  43047. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43048. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43049. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43050. getRenderWidth(useScreen?: boolean): number;
  43051. getRenderHeight(useScreen?: boolean): number;
  43052. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43053. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43054. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43055. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43056. bindSamplers(effect: Effect): void;
  43057. enableEffect(effect: Effect): void;
  43058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43059. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43060. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43061. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43062. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43063. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43064. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43065. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43066. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43067. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43068. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43069. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43070. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43071. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43072. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43073. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43074. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43075. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43076. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43077. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43078. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43079. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43080. bindBuffers(vertexBuffers: {
  43081. [key: string]: VertexBuffer;
  43082. }, indexBuffer: DataBuffer, effect: Effect): void;
  43083. wipeCaches(bruteForce?: boolean): void;
  43084. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43085. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43086. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43087. /** @hidden */
  43088. _createTexture(): WebGLTexture;
  43089. /** @hidden */
  43090. _releaseTexture(texture: InternalTexture): void;
  43091. 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;
  43092. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43094. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43095. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43096. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43097. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43098. areAllEffectsReady(): boolean;
  43099. /**
  43100. * @hidden
  43101. * Get the current error code of the webGL context
  43102. * @returns the error code
  43103. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43104. */
  43105. getError(): number;
  43106. /** @hidden */
  43107. _getUnpackAlignement(): number;
  43108. /** @hidden */
  43109. _unpackFlipY(value: boolean): void;
  43110. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43111. /**
  43112. * Updates a dynamic vertex buffer.
  43113. * @param vertexBuffer the vertex buffer to update
  43114. * @param data the data used to update the vertex buffer
  43115. * @param byteOffset the byte offset of the data (optional)
  43116. * @param byteLength the byte length of the data (optional)
  43117. */
  43118. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43119. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43120. /** @hidden */
  43121. _bindTexture(channel: number, texture: InternalTexture): void;
  43122. /** @hidden */
  43123. _releaseBuffer(buffer: DataBuffer): boolean;
  43124. releaseEffects(): void;
  43125. displayLoadingUI(): void;
  43126. hideLoadingUI(): void;
  43127. /** @hidden */
  43128. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43129. /** @hidden */
  43130. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43131. /** @hidden */
  43132. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43133. /** @hidden */
  43134. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43135. }
  43136. }
  43137. declare module BABYLON {
  43138. /** @hidden */
  43139. export class _OcclusionDataStorage {
  43140. /** @hidden */
  43141. occlusionInternalRetryCounter: number;
  43142. /** @hidden */
  43143. isOcclusionQueryInProgress: boolean;
  43144. /** @hidden */
  43145. isOccluded: boolean;
  43146. /** @hidden */
  43147. occlusionRetryCount: number;
  43148. /** @hidden */
  43149. occlusionType: number;
  43150. /** @hidden */
  43151. occlusionQueryAlgorithmType: number;
  43152. }
  43153. interface Engine {
  43154. /**
  43155. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43156. * @return the new query
  43157. */
  43158. createQuery(): WebGLQuery;
  43159. /**
  43160. * Delete and release a webGL query
  43161. * @param query defines the query to delete
  43162. * @return the current engine
  43163. */
  43164. deleteQuery(query: WebGLQuery): Engine;
  43165. /**
  43166. * Check if a given query has resolved and got its value
  43167. * @param query defines the query to check
  43168. * @returns true if the query got its value
  43169. */
  43170. isQueryResultAvailable(query: WebGLQuery): boolean;
  43171. /**
  43172. * Gets the value of a given query
  43173. * @param query defines the query to check
  43174. * @returns the value of the query
  43175. */
  43176. getQueryResult(query: WebGLQuery): number;
  43177. /**
  43178. * Initiates an occlusion query
  43179. * @param algorithmType defines the algorithm to use
  43180. * @param query defines the query to use
  43181. * @returns the current engine
  43182. * @see http://doc.babylonjs.com/features/occlusionquery
  43183. */
  43184. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43185. /**
  43186. * Ends an occlusion query
  43187. * @see http://doc.babylonjs.com/features/occlusionquery
  43188. * @param algorithmType defines the algorithm to use
  43189. * @returns the current engine
  43190. */
  43191. endOcclusionQuery(algorithmType: number): Engine;
  43192. /**
  43193. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43194. * Please note that only one query can be issued at a time
  43195. * @returns a time token used to track the time span
  43196. */
  43197. startTimeQuery(): Nullable<_TimeToken>;
  43198. /**
  43199. * Ends a time query
  43200. * @param token defines the token used to measure the time span
  43201. * @returns the time spent (in ns)
  43202. */
  43203. endTimeQuery(token: _TimeToken): int;
  43204. /** @hidden */
  43205. _currentNonTimestampToken: Nullable<_TimeToken>;
  43206. /** @hidden */
  43207. _createTimeQuery(): WebGLQuery;
  43208. /** @hidden */
  43209. _deleteTimeQuery(query: WebGLQuery): void;
  43210. /** @hidden */
  43211. _getGlAlgorithmType(algorithmType: number): number;
  43212. /** @hidden */
  43213. _getTimeQueryResult(query: WebGLQuery): any;
  43214. /** @hidden */
  43215. _getTimeQueryAvailability(query: WebGLQuery): any;
  43216. }
  43217. interface AbstractMesh {
  43218. /**
  43219. * Backing filed
  43220. * @hidden
  43221. */
  43222. __occlusionDataStorage: _OcclusionDataStorage;
  43223. /**
  43224. * Access property
  43225. * @hidden
  43226. */
  43227. _occlusionDataStorage: _OcclusionDataStorage;
  43228. /**
  43229. * 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.
  43230. * The default value is -1 which means don't break the query and wait till the result
  43231. * @see http://doc.babylonjs.com/features/occlusionquery
  43232. */
  43233. occlusionRetryCount: number;
  43234. /**
  43235. * 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:
  43236. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43237. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43238. * * 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.
  43239. * @see http://doc.babylonjs.com/features/occlusionquery
  43240. */
  43241. occlusionType: number;
  43242. /**
  43243. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43244. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43245. * * 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.
  43246. * @see http://doc.babylonjs.com/features/occlusionquery
  43247. */
  43248. occlusionQueryAlgorithmType: number;
  43249. /**
  43250. * 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
  43251. * @see http://doc.babylonjs.com/features/occlusionquery
  43252. */
  43253. isOccluded: boolean;
  43254. /**
  43255. * Flag to check the progress status of the query
  43256. * @see http://doc.babylonjs.com/features/occlusionquery
  43257. */
  43258. isOcclusionQueryInProgress: boolean;
  43259. }
  43260. }
  43261. declare module BABYLON {
  43262. /** @hidden */
  43263. export var _forceTransformFeedbackToBundle: boolean;
  43264. interface Engine {
  43265. /**
  43266. * Creates a webGL transform feedback object
  43267. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43268. * @returns the webGL transform feedback object
  43269. */
  43270. createTransformFeedback(): WebGLTransformFeedback;
  43271. /**
  43272. * Delete a webGL transform feedback object
  43273. * @param value defines the webGL transform feedback object to delete
  43274. */
  43275. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43276. /**
  43277. * Bind a webGL transform feedback object to the webgl context
  43278. * @param value defines the webGL transform feedback object to bind
  43279. */
  43280. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43281. /**
  43282. * Begins a transform feedback operation
  43283. * @param usePoints defines if points or triangles must be used
  43284. */
  43285. beginTransformFeedback(usePoints: boolean): void;
  43286. /**
  43287. * Ends a transform feedback operation
  43288. */
  43289. endTransformFeedback(): void;
  43290. /**
  43291. * Specify the varyings to use with transform feedback
  43292. * @param program defines the associated webGL program
  43293. * @param value defines the list of strings representing the varying names
  43294. */
  43295. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43296. /**
  43297. * Bind a webGL buffer for a transform feedback operation
  43298. * @param value defines the webGL buffer to bind
  43299. */
  43300. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43301. }
  43302. }
  43303. declare module BABYLON {
  43304. /**
  43305. * Creation options of the multi render target texture.
  43306. */
  43307. export interface IMultiRenderTargetOptions {
  43308. /**
  43309. * Define if the texture needs to create mip maps after render.
  43310. */
  43311. generateMipMaps?: boolean;
  43312. /**
  43313. * Define the types of all the draw buffers we want to create
  43314. */
  43315. types?: number[];
  43316. /**
  43317. * Define the sampling modes of all the draw buffers we want to create
  43318. */
  43319. samplingModes?: number[];
  43320. /**
  43321. * Define if a depth buffer is required
  43322. */
  43323. generateDepthBuffer?: boolean;
  43324. /**
  43325. * Define if a stencil buffer is required
  43326. */
  43327. generateStencilBuffer?: boolean;
  43328. /**
  43329. * Define if a depth texture is required instead of a depth buffer
  43330. */
  43331. generateDepthTexture?: boolean;
  43332. /**
  43333. * Define the number of desired draw buffers
  43334. */
  43335. textureCount?: number;
  43336. /**
  43337. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43338. */
  43339. doNotChangeAspectRatio?: boolean;
  43340. /**
  43341. * Define the default type of the buffers we are creating
  43342. */
  43343. defaultType?: number;
  43344. }
  43345. /**
  43346. * A multi render target, like a render target provides the ability to render to a texture.
  43347. * Unlike the render target, it can render to several draw buffers in one draw.
  43348. * This is specially interesting in deferred rendering or for any effects requiring more than
  43349. * just one color from a single pass.
  43350. */
  43351. export class MultiRenderTarget extends RenderTargetTexture {
  43352. private _internalTextures;
  43353. private _textures;
  43354. private _multiRenderTargetOptions;
  43355. /**
  43356. * Get if draw buffers are currently supported by the used hardware and browser.
  43357. */
  43358. readonly isSupported: boolean;
  43359. /**
  43360. * Get the list of textures generated by the multi render target.
  43361. */
  43362. readonly textures: Texture[];
  43363. /**
  43364. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43365. */
  43366. readonly depthTexture: Texture;
  43367. /**
  43368. * Set the wrapping mode on U of all the textures we are rendering to.
  43369. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43370. */
  43371. wrapU: number;
  43372. /**
  43373. * Set the wrapping mode on V of all the textures we are rendering to.
  43374. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43375. */
  43376. wrapV: number;
  43377. /**
  43378. * Instantiate a new multi render target texture.
  43379. * A multi render target, like a render target provides the ability to render to a texture.
  43380. * Unlike the render target, it can render to several draw buffers in one draw.
  43381. * This is specially interesting in deferred rendering or for any effects requiring more than
  43382. * just one color from a single pass.
  43383. * @param name Define the name of the texture
  43384. * @param size Define the size of the buffers to render to
  43385. * @param count Define the number of target we are rendering into
  43386. * @param scene Define the scene the texture belongs to
  43387. * @param options Define the options used to create the multi render target
  43388. */
  43389. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43390. /** @hidden */
  43391. _rebuild(): void;
  43392. private _createInternalTextures;
  43393. private _createTextures;
  43394. /**
  43395. * Define the number of samples used if MSAA is enabled.
  43396. */
  43397. samples: number;
  43398. /**
  43399. * Resize all the textures in the multi render target.
  43400. * Be carrefull as it will recreate all the data in the new texture.
  43401. * @param size Define the new size
  43402. */
  43403. resize(size: any): void;
  43404. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43405. /**
  43406. * Dispose the render targets and their associated resources
  43407. */
  43408. dispose(): void;
  43409. /**
  43410. * Release all the underlying texture used as draw buffers.
  43411. */
  43412. releaseInternalTextures(): void;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. interface Engine {
  43417. /**
  43418. * Unbind a list of render target textures from the webGL context
  43419. * This is used only when drawBuffer extension or webGL2 are active
  43420. * @param textures defines the render target textures to unbind
  43421. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43422. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43423. */
  43424. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43425. /**
  43426. * Create a multi render target texture
  43427. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43428. * @param size defines the size of the texture
  43429. * @param options defines the creation options
  43430. * @returns the cube texture as an InternalTexture
  43431. */
  43432. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43433. /**
  43434. * Update the sample count for a given multiple render target texture
  43435. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43436. * @param textures defines the textures to update
  43437. * @param samples defines the sample count to set
  43438. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43439. */
  43440. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43441. }
  43442. }
  43443. declare module BABYLON {
  43444. /**
  43445. * Gather the list of clipboard event types as constants.
  43446. */
  43447. export class ClipboardEventTypes {
  43448. /**
  43449. * The clipboard event is fired when a copy command is active (pressed).
  43450. */
  43451. static readonly COPY: number;
  43452. /**
  43453. * The clipboard event is fired when a cut command is active (pressed).
  43454. */
  43455. static readonly CUT: number;
  43456. /**
  43457. * The clipboard event is fired when a paste command is active (pressed).
  43458. */
  43459. static readonly PASTE: number;
  43460. }
  43461. /**
  43462. * This class is used to store clipboard related info for the onClipboardObservable event.
  43463. */
  43464. export class ClipboardInfo {
  43465. /**
  43466. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43467. */
  43468. type: number;
  43469. /**
  43470. * Defines the related dom event
  43471. */
  43472. event: ClipboardEvent;
  43473. /**
  43474. *Creates an instance of ClipboardInfo.
  43475. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43476. * @param event Defines the related dom event
  43477. */
  43478. constructor(
  43479. /**
  43480. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43481. */
  43482. type: number,
  43483. /**
  43484. * Defines the related dom event
  43485. */
  43486. event: ClipboardEvent);
  43487. /**
  43488. * Get the clipboard event's type from the keycode.
  43489. * @param keyCode Defines the keyCode for the current keyboard event.
  43490. * @return {number}
  43491. */
  43492. static GetTypeFromCharacter(keyCode: number): number;
  43493. }
  43494. }
  43495. declare module BABYLON {
  43496. /**
  43497. * Google Daydream controller
  43498. */
  43499. export class DaydreamController extends WebVRController {
  43500. /**
  43501. * Base Url for the controller model.
  43502. */
  43503. static MODEL_BASE_URL: string;
  43504. /**
  43505. * File name for the controller model.
  43506. */
  43507. static MODEL_FILENAME: string;
  43508. /**
  43509. * Gamepad Id prefix used to identify Daydream Controller.
  43510. */
  43511. static readonly GAMEPAD_ID_PREFIX: string;
  43512. /**
  43513. * Creates a new DaydreamController from a gamepad
  43514. * @param vrGamepad the gamepad that the controller should be created from
  43515. */
  43516. constructor(vrGamepad: any);
  43517. /**
  43518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43519. * @param scene scene in which to add meshes
  43520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43521. */
  43522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43523. /**
  43524. * Called once for each button that changed state since the last frame
  43525. * @param buttonIdx Which button index changed
  43526. * @param state New state of the button
  43527. * @param changes Which properties on the state changed since last frame
  43528. */
  43529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43530. }
  43531. }
  43532. declare module BABYLON {
  43533. /**
  43534. * Gear VR Controller
  43535. */
  43536. export class GearVRController extends WebVRController {
  43537. /**
  43538. * Base Url for the controller model.
  43539. */
  43540. static MODEL_BASE_URL: string;
  43541. /**
  43542. * File name for the controller model.
  43543. */
  43544. static MODEL_FILENAME: string;
  43545. /**
  43546. * Gamepad Id prefix used to identify this controller.
  43547. */
  43548. static readonly GAMEPAD_ID_PREFIX: string;
  43549. private readonly _buttonIndexToObservableNameMap;
  43550. /**
  43551. * Creates a new GearVRController from a gamepad
  43552. * @param vrGamepad the gamepad that the controller should be created from
  43553. */
  43554. constructor(vrGamepad: any);
  43555. /**
  43556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43557. * @param scene scene in which to add meshes
  43558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43559. */
  43560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43561. /**
  43562. * Called once for each button that changed state since the last frame
  43563. * @param buttonIdx Which button index changed
  43564. * @param state New state of the button
  43565. * @param changes Which properties on the state changed since last frame
  43566. */
  43567. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43568. }
  43569. }
  43570. declare module BABYLON {
  43571. /**
  43572. * Class containing static functions to help procedurally build meshes
  43573. */
  43574. export class PolyhedronBuilder {
  43575. /**
  43576. * Creates a polyhedron mesh
  43577. * * 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
  43578. * * The parameter `size` (positive float, default 1) sets the polygon size
  43579. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43580. * * 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`
  43581. * * 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
  43582. * * 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)`)
  43583. * * 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
  43584. * * 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
  43585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43586. * * 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
  43587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43588. * @param name defines the name of the mesh
  43589. * @param options defines the options used to create the mesh
  43590. * @param scene defines the hosting scene
  43591. * @returns the polyhedron mesh
  43592. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43593. */
  43594. static CreatePolyhedron(name: string, options: {
  43595. type?: number;
  43596. size?: number;
  43597. sizeX?: number;
  43598. sizeY?: number;
  43599. sizeZ?: number;
  43600. custom?: any;
  43601. faceUV?: Vector4[];
  43602. faceColors?: Color4[];
  43603. flat?: boolean;
  43604. updatable?: boolean;
  43605. sideOrientation?: number;
  43606. frontUVs?: Vector4;
  43607. backUVs?: Vector4;
  43608. }, scene?: Nullable<Scene>): Mesh;
  43609. }
  43610. }
  43611. declare module BABYLON {
  43612. /**
  43613. * Gizmo that enables scaling a mesh along 3 axis
  43614. */
  43615. export class ScaleGizmo extends Gizmo {
  43616. /**
  43617. * Internal gizmo used for interactions on the x axis
  43618. */
  43619. xGizmo: AxisScaleGizmo;
  43620. /**
  43621. * Internal gizmo used for interactions on the y axis
  43622. */
  43623. yGizmo: AxisScaleGizmo;
  43624. /**
  43625. * Internal gizmo used for interactions on the z axis
  43626. */
  43627. zGizmo: AxisScaleGizmo;
  43628. /**
  43629. * Internal gizmo used to scale all axis equally
  43630. */
  43631. uniformScaleGizmo: AxisScaleGizmo;
  43632. private _meshAttached;
  43633. private _updateGizmoRotationToMatchAttachedMesh;
  43634. private _snapDistance;
  43635. private _scaleRatio;
  43636. private _uniformScalingMesh;
  43637. private _octahedron;
  43638. /** Fires an event when any of it's sub gizmos are dragged */
  43639. onDragStartObservable: Observable<unknown>;
  43640. /** Fires an event when any of it's sub gizmos are released from dragging */
  43641. onDragEndObservable: Observable<unknown>;
  43642. attachedMesh: Nullable<AbstractMesh>;
  43643. /**
  43644. * Creates a ScaleGizmo
  43645. * @param gizmoLayer The utility layer the gizmo will be added to
  43646. */
  43647. constructor(gizmoLayer?: UtilityLayerRenderer);
  43648. updateGizmoRotationToMatchAttachedMesh: boolean;
  43649. /**
  43650. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43651. */
  43652. snapDistance: number;
  43653. /**
  43654. * Ratio for the scale of the gizmo (Default: 1)
  43655. */
  43656. scaleRatio: number;
  43657. /**
  43658. * Disposes of the gizmo
  43659. */
  43660. dispose(): void;
  43661. }
  43662. }
  43663. declare module BABYLON {
  43664. /**
  43665. * Single axis scale gizmo
  43666. */
  43667. export class AxisScaleGizmo extends Gizmo {
  43668. /**
  43669. * Drag behavior responsible for the gizmos dragging interactions
  43670. */
  43671. dragBehavior: PointerDragBehavior;
  43672. private _pointerObserver;
  43673. /**
  43674. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43675. */
  43676. snapDistance: number;
  43677. /**
  43678. * Event that fires each time the gizmo snaps to a new location.
  43679. * * snapDistance is the the change in distance
  43680. */
  43681. onSnapObservable: Observable<{
  43682. snapDistance: number;
  43683. }>;
  43684. /**
  43685. * If the scaling operation should be done on all axis (default: false)
  43686. */
  43687. uniformScaling: boolean;
  43688. private _isEnabled;
  43689. private _parent;
  43690. private _arrow;
  43691. private _coloredMaterial;
  43692. private _hoverMaterial;
  43693. /**
  43694. * Creates an AxisScaleGizmo
  43695. * @param gizmoLayer The utility layer the gizmo will be added to
  43696. * @param dragAxis The axis which the gizmo will be able to scale on
  43697. * @param color The color of the gizmo
  43698. */
  43699. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43701. /**
  43702. * If the gizmo is enabled
  43703. */
  43704. isEnabled: boolean;
  43705. /**
  43706. * Disposes of the gizmo
  43707. */
  43708. dispose(): void;
  43709. /**
  43710. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43711. * @param mesh The mesh to replace the default mesh of the gizmo
  43712. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43713. */
  43714. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43715. }
  43716. }
  43717. declare module BABYLON {
  43718. /**
  43719. * Bounding box gizmo
  43720. */
  43721. export class BoundingBoxGizmo extends Gizmo {
  43722. private _lineBoundingBox;
  43723. private _rotateSpheresParent;
  43724. private _scaleBoxesParent;
  43725. private _boundingDimensions;
  43726. private _renderObserver;
  43727. private _pointerObserver;
  43728. private _scaleDragSpeed;
  43729. private _tmpQuaternion;
  43730. private _tmpVector;
  43731. private _tmpRotationMatrix;
  43732. /**
  43733. * 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)
  43734. */
  43735. ignoreChildren: boolean;
  43736. /**
  43737. * 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)
  43738. */
  43739. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43740. /**
  43741. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43742. */
  43743. rotationSphereSize: number;
  43744. /**
  43745. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43746. */
  43747. scaleBoxSize: number;
  43748. /**
  43749. * 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)
  43750. */
  43751. fixedDragMeshScreenSize: boolean;
  43752. /**
  43753. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43754. */
  43755. fixedDragMeshScreenSizeDistanceFactor: number;
  43756. /**
  43757. * Fired when a rotation sphere or scale box is dragged
  43758. */
  43759. onDragStartObservable: Observable<{}>;
  43760. /**
  43761. * Fired when a scale box is dragged
  43762. */
  43763. onScaleBoxDragObservable: Observable<{}>;
  43764. /**
  43765. * Fired when a scale box drag is ended
  43766. */
  43767. onScaleBoxDragEndObservable: Observable<{}>;
  43768. /**
  43769. * Fired when a rotation sphere is dragged
  43770. */
  43771. onRotationSphereDragObservable: Observable<{}>;
  43772. /**
  43773. * Fired when a rotation sphere drag is ended
  43774. */
  43775. onRotationSphereDragEndObservable: Observable<{}>;
  43776. /**
  43777. * 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)
  43778. */
  43779. scalePivot: Nullable<Vector3>;
  43780. /**
  43781. * Mesh used as a pivot to rotate the attached mesh
  43782. */
  43783. private _anchorMesh;
  43784. private _existingMeshScale;
  43785. private _dragMesh;
  43786. private pointerDragBehavior;
  43787. private coloredMaterial;
  43788. private hoverColoredMaterial;
  43789. /**
  43790. * Sets the color of the bounding box gizmo
  43791. * @param color the color to set
  43792. */
  43793. setColor(color: Color3): void;
  43794. /**
  43795. * Creates an BoundingBoxGizmo
  43796. * @param gizmoLayer The utility layer the gizmo will be added to
  43797. * @param color The color of the gizmo
  43798. */
  43799. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43800. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43801. private _selectNode;
  43802. /**
  43803. * Updates the bounding box information for the Gizmo
  43804. */
  43805. updateBoundingBox(): void;
  43806. private _updateRotationSpheres;
  43807. private _updateScaleBoxes;
  43808. /**
  43809. * Enables rotation on the specified axis and disables rotation on the others
  43810. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43811. */
  43812. setEnabledRotationAxis(axis: string): void;
  43813. /**
  43814. * Enables/disables scaling
  43815. * @param enable if scaling should be enabled
  43816. */
  43817. setEnabledScaling(enable: boolean): void;
  43818. private _updateDummy;
  43819. /**
  43820. * Enables a pointer drag behavior on the bounding box of the gizmo
  43821. */
  43822. enableDragBehavior(): void;
  43823. /**
  43824. * Disposes of the gizmo
  43825. */
  43826. dispose(): void;
  43827. /**
  43828. * 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)
  43829. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43830. * @returns the bounding box mesh with the passed in mesh as a child
  43831. */
  43832. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43833. /**
  43834. * CustomMeshes are not supported by this gizmo
  43835. * @param mesh The mesh to replace the default mesh of the gizmo
  43836. */
  43837. setCustomMesh(mesh: Mesh): void;
  43838. }
  43839. }
  43840. declare module BABYLON {
  43841. /**
  43842. * Single plane rotation gizmo
  43843. */
  43844. export class PlaneRotationGizmo extends Gizmo {
  43845. /**
  43846. * Drag behavior responsible for the gizmos dragging interactions
  43847. */
  43848. dragBehavior: PointerDragBehavior;
  43849. private _pointerObserver;
  43850. /**
  43851. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43852. */
  43853. snapDistance: number;
  43854. /**
  43855. * Event that fires each time the gizmo snaps to a new location.
  43856. * * snapDistance is the the change in distance
  43857. */
  43858. onSnapObservable: Observable<{
  43859. snapDistance: number;
  43860. }>;
  43861. private _isEnabled;
  43862. private _parent;
  43863. /**
  43864. * Creates a PlaneRotationGizmo
  43865. * @param gizmoLayer The utility layer the gizmo will be added to
  43866. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43867. * @param color The color of the gizmo
  43868. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43869. */
  43870. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43871. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43872. /**
  43873. * If the gizmo is enabled
  43874. */
  43875. isEnabled: boolean;
  43876. /**
  43877. * Disposes of the gizmo
  43878. */
  43879. dispose(): void;
  43880. }
  43881. }
  43882. declare module BABYLON {
  43883. /**
  43884. * Gizmo that enables rotating a mesh along 3 axis
  43885. */
  43886. export class RotationGizmo extends Gizmo {
  43887. /**
  43888. * Internal gizmo used for interactions on the x axis
  43889. */
  43890. xGizmo: PlaneRotationGizmo;
  43891. /**
  43892. * Internal gizmo used for interactions on the y axis
  43893. */
  43894. yGizmo: PlaneRotationGizmo;
  43895. /**
  43896. * Internal gizmo used for interactions on the z axis
  43897. */
  43898. zGizmo: PlaneRotationGizmo;
  43899. /** Fires an event when any of it's sub gizmos are dragged */
  43900. onDragStartObservable: Observable<unknown>;
  43901. /** Fires an event when any of it's sub gizmos are released from dragging */
  43902. onDragEndObservable: Observable<unknown>;
  43903. private _meshAttached;
  43904. attachedMesh: Nullable<AbstractMesh>;
  43905. /**
  43906. * Creates a RotationGizmo
  43907. * @param gizmoLayer The utility layer the gizmo will be added to
  43908. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43909. */
  43910. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43911. updateGizmoRotationToMatchAttachedMesh: boolean;
  43912. /**
  43913. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43914. */
  43915. snapDistance: number;
  43916. /**
  43917. * Ratio for the scale of the gizmo (Default: 1)
  43918. */
  43919. scaleRatio: number;
  43920. /**
  43921. * Disposes of the gizmo
  43922. */
  43923. dispose(): void;
  43924. /**
  43925. * CustomMeshes are not supported by this gizmo
  43926. * @param mesh The mesh to replace the default mesh of the gizmo
  43927. */
  43928. setCustomMesh(mesh: Mesh): void;
  43929. }
  43930. }
  43931. declare module BABYLON {
  43932. /**
  43933. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43934. */
  43935. export class GizmoManager implements IDisposable {
  43936. private scene;
  43937. /**
  43938. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43939. */
  43940. gizmos: {
  43941. positionGizmo: Nullable<PositionGizmo>;
  43942. rotationGizmo: Nullable<RotationGizmo>;
  43943. scaleGizmo: Nullable<ScaleGizmo>;
  43944. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43945. };
  43946. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43947. clearGizmoOnEmptyPointerEvent: boolean;
  43948. /** Fires an event when the manager is attached to a mesh */
  43949. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43950. private _gizmosEnabled;
  43951. private _pointerObserver;
  43952. private _attachedMesh;
  43953. private _boundingBoxColor;
  43954. private _defaultUtilityLayer;
  43955. private _defaultKeepDepthUtilityLayer;
  43956. /**
  43957. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43958. */
  43959. boundingBoxDragBehavior: SixDofDragBehavior;
  43960. /**
  43961. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43962. */
  43963. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43964. /**
  43965. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43966. */
  43967. usePointerToAttachGizmos: boolean;
  43968. /**
  43969. * Utility layer that the bounding box gizmo belongs to
  43970. */
  43971. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43972. /**
  43973. * Utility layer that all gizmos besides bounding box belong to
  43974. */
  43975. readonly utilityLayer: UtilityLayerRenderer;
  43976. /**
  43977. * Instatiates a gizmo manager
  43978. * @param scene the scene to overlay the gizmos on top of
  43979. */
  43980. constructor(scene: Scene);
  43981. /**
  43982. * Attaches a set of gizmos to the specified mesh
  43983. * @param mesh The mesh the gizmo's should be attached to
  43984. */
  43985. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43986. /**
  43987. * If the position gizmo is enabled
  43988. */
  43989. positionGizmoEnabled: boolean;
  43990. /**
  43991. * If the rotation gizmo is enabled
  43992. */
  43993. rotationGizmoEnabled: boolean;
  43994. /**
  43995. * If the scale gizmo is enabled
  43996. */
  43997. scaleGizmoEnabled: boolean;
  43998. /**
  43999. * If the boundingBox gizmo is enabled
  44000. */
  44001. boundingBoxGizmoEnabled: boolean;
  44002. /**
  44003. * Disposes of the gizmo manager
  44004. */
  44005. dispose(): void;
  44006. }
  44007. }
  44008. declare module BABYLON {
  44009. /**
  44010. * A directional light is defined by a direction (what a surprise!).
  44011. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44012. * 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.
  44013. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44014. */
  44015. export class DirectionalLight extends ShadowLight {
  44016. private _shadowFrustumSize;
  44017. /**
  44018. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44019. */
  44020. /**
  44021. * Specifies a fix frustum size for the shadow generation.
  44022. */
  44023. shadowFrustumSize: number;
  44024. private _shadowOrthoScale;
  44025. /**
  44026. * Gets the shadow projection scale against the optimal computed one.
  44027. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44028. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44029. */
  44030. /**
  44031. * Sets the shadow projection scale against the optimal computed one.
  44032. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44033. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44034. */
  44035. shadowOrthoScale: number;
  44036. /**
  44037. * Automatically compute the projection matrix to best fit (including all the casters)
  44038. * on each frame.
  44039. */
  44040. autoUpdateExtends: boolean;
  44041. private _orthoLeft;
  44042. private _orthoRight;
  44043. private _orthoTop;
  44044. private _orthoBottom;
  44045. /**
  44046. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44047. * The directional light is emitted from everywhere in the given direction.
  44048. * It can cast shadows.
  44049. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44050. * @param name The friendly name of the light
  44051. * @param direction The direction of the light
  44052. * @param scene The scene the light belongs to
  44053. */
  44054. constructor(name: string, direction: Vector3, scene: Scene);
  44055. /**
  44056. * Returns the string "DirectionalLight".
  44057. * @return The class name
  44058. */
  44059. getClassName(): string;
  44060. /**
  44061. * Returns the integer 1.
  44062. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44063. */
  44064. getTypeID(): number;
  44065. /**
  44066. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44067. * Returns the DirectionalLight Shadow projection matrix.
  44068. */
  44069. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44070. /**
  44071. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44072. * Returns the DirectionalLight Shadow projection matrix.
  44073. */
  44074. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44075. /**
  44076. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44077. * Returns the DirectionalLight Shadow projection matrix.
  44078. */
  44079. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44080. protected _buildUniformLayout(): void;
  44081. /**
  44082. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44083. * @param effect The effect to update
  44084. * @param lightIndex The index of the light in the effect to update
  44085. * @returns The directional light
  44086. */
  44087. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44088. /**
  44089. * Gets the minZ used for shadow according to both the scene and the light.
  44090. *
  44091. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44092. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44093. * @param activeCamera The camera we are returning the min for
  44094. * @returns the depth min z
  44095. */
  44096. getDepthMinZ(activeCamera: Camera): number;
  44097. /**
  44098. * Gets the maxZ used for shadow according to both the scene and the light.
  44099. *
  44100. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44101. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44102. * @param activeCamera The camera we are returning the max for
  44103. * @returns the depth max z
  44104. */
  44105. getDepthMaxZ(activeCamera: Camera): number;
  44106. /**
  44107. * Prepares the list of defines specific to the light type.
  44108. * @param defines the list of defines
  44109. * @param lightIndex defines the index of the light for the effect
  44110. */
  44111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44112. }
  44113. }
  44114. declare module BABYLON {
  44115. /**
  44116. * Class containing static functions to help procedurally build meshes
  44117. */
  44118. export class HemisphereBuilder {
  44119. /**
  44120. * Creates a hemisphere mesh
  44121. * @param name defines the name of the mesh
  44122. * @param options defines the options used to create the mesh
  44123. * @param scene defines the hosting scene
  44124. * @returns the hemisphere mesh
  44125. */
  44126. static CreateHemisphere(name: string, options: {
  44127. segments?: number;
  44128. diameter?: number;
  44129. sideOrientation?: number;
  44130. }, scene: any): Mesh;
  44131. }
  44132. }
  44133. declare module BABYLON {
  44134. /**
  44135. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44136. * These values define a cone of light starting from the position, emitting toward the direction.
  44137. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44138. * and the exponent defines the speed of the decay of the light with distance (reach).
  44139. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44140. */
  44141. export class SpotLight extends ShadowLight {
  44142. private _angle;
  44143. private _innerAngle;
  44144. private _cosHalfAngle;
  44145. private _lightAngleScale;
  44146. private _lightAngleOffset;
  44147. /**
  44148. * Gets the cone angle of the spot light in Radians.
  44149. */
  44150. /**
  44151. * Sets the cone angle of the spot light in Radians.
  44152. */
  44153. angle: number;
  44154. /**
  44155. * Only used in gltf falloff mode, this defines the angle where
  44156. * the directional falloff will start before cutting at angle which could be seen
  44157. * as outer angle.
  44158. */
  44159. /**
  44160. * Only used in gltf falloff mode, this defines the angle where
  44161. * the directional falloff will start before cutting at angle which could be seen
  44162. * as outer angle.
  44163. */
  44164. innerAngle: number;
  44165. private _shadowAngleScale;
  44166. /**
  44167. * Allows scaling the angle of the light for shadow generation only.
  44168. */
  44169. /**
  44170. * Allows scaling the angle of the light for shadow generation only.
  44171. */
  44172. shadowAngleScale: number;
  44173. /**
  44174. * The light decay speed with the distance from the emission spot.
  44175. */
  44176. exponent: number;
  44177. private _projectionTextureMatrix;
  44178. /**
  44179. * Allows reading the projecton texture
  44180. */
  44181. readonly projectionTextureMatrix: Matrix;
  44182. protected _projectionTextureLightNear: number;
  44183. /**
  44184. * Gets the near clip of the Spotlight for texture projection.
  44185. */
  44186. /**
  44187. * Sets the near clip of the Spotlight for texture projection.
  44188. */
  44189. projectionTextureLightNear: number;
  44190. protected _projectionTextureLightFar: number;
  44191. /**
  44192. * Gets the far clip of the Spotlight for texture projection.
  44193. */
  44194. /**
  44195. * Sets the far clip of the Spotlight for texture projection.
  44196. */
  44197. projectionTextureLightFar: number;
  44198. protected _projectionTextureUpDirection: Vector3;
  44199. /**
  44200. * Gets the Up vector of the Spotlight for texture projection.
  44201. */
  44202. /**
  44203. * Sets the Up vector of the Spotlight for texture projection.
  44204. */
  44205. projectionTextureUpDirection: Vector3;
  44206. private _projectionTexture;
  44207. /**
  44208. * Gets the projection texture of the light.
  44209. */
  44210. /**
  44211. * Sets the projection texture of the light.
  44212. */
  44213. projectionTexture: Nullable<BaseTexture>;
  44214. private _projectionTextureViewLightDirty;
  44215. private _projectionTextureProjectionLightDirty;
  44216. private _projectionTextureDirty;
  44217. private _projectionTextureViewTargetVector;
  44218. private _projectionTextureViewLightMatrix;
  44219. private _projectionTextureProjectionLightMatrix;
  44220. private _projectionTextureScalingMatrix;
  44221. /**
  44222. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44223. * It can cast shadows.
  44224. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44225. * @param name The light friendly name
  44226. * @param position The position of the spot light in the scene
  44227. * @param direction The direction of the light in the scene
  44228. * @param angle The cone angle of the light in Radians
  44229. * @param exponent The light decay speed with the distance from the emission spot
  44230. * @param scene The scene the lights belongs to
  44231. */
  44232. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44233. /**
  44234. * Returns the string "SpotLight".
  44235. * @returns the class name
  44236. */
  44237. getClassName(): string;
  44238. /**
  44239. * Returns the integer 2.
  44240. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44241. */
  44242. getTypeID(): number;
  44243. /**
  44244. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44245. */
  44246. protected _setDirection(value: Vector3): void;
  44247. /**
  44248. * Overrides the position setter to recompute the projection texture view light Matrix.
  44249. */
  44250. protected _setPosition(value: Vector3): void;
  44251. /**
  44252. * 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.
  44253. * Returns the SpotLight.
  44254. */
  44255. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44256. protected _computeProjectionTextureViewLightMatrix(): void;
  44257. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44258. /**
  44259. * Main function for light texture projection matrix computing.
  44260. */
  44261. protected _computeProjectionTextureMatrix(): void;
  44262. protected _buildUniformLayout(): void;
  44263. private _computeAngleValues;
  44264. /**
  44265. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44266. * @param effect The effect to update
  44267. * @param lightIndex The index of the light in the effect to update
  44268. * @returns The spot light
  44269. */
  44270. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44271. /**
  44272. * Disposes the light and the associated resources.
  44273. */
  44274. dispose(): void;
  44275. /**
  44276. * Prepares the list of defines specific to the light type.
  44277. * @param defines the list of defines
  44278. * @param lightIndex defines the index of the light for the effect
  44279. */
  44280. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44281. }
  44282. }
  44283. declare module BABYLON {
  44284. /**
  44285. * Gizmo that enables viewing a light
  44286. */
  44287. export class LightGizmo extends Gizmo {
  44288. private _lightMesh;
  44289. private _material;
  44290. private cachedPosition;
  44291. private cachedForward;
  44292. /**
  44293. * Creates a LightGizmo
  44294. * @param gizmoLayer The utility layer the gizmo will be added to
  44295. */
  44296. constructor(gizmoLayer?: UtilityLayerRenderer);
  44297. private _light;
  44298. /**
  44299. * The light that the gizmo is attached to
  44300. */
  44301. light: Nullable<Light>;
  44302. /**
  44303. * @hidden
  44304. * Updates the gizmo to match the attached mesh's position/rotation
  44305. */
  44306. protected _update(): void;
  44307. private static _Scale;
  44308. /**
  44309. * Creates the lines for a light mesh
  44310. */
  44311. private static _createLightLines;
  44312. /**
  44313. * Disposes of the light gizmo
  44314. */
  44315. dispose(): void;
  44316. private static _CreateHemisphericLightMesh;
  44317. private static _CreatePointLightMesh;
  44318. private static _CreateSpotLightMesh;
  44319. private static _CreateDirectionalLightMesh;
  44320. }
  44321. }
  44322. declare module BABYLON {
  44323. /** @hidden */
  44324. export var backgroundFragmentDeclaration: {
  44325. name: string;
  44326. shader: string;
  44327. };
  44328. }
  44329. declare module BABYLON {
  44330. /** @hidden */
  44331. export var backgroundUboDeclaration: {
  44332. name: string;
  44333. shader: string;
  44334. };
  44335. }
  44336. declare module BABYLON {
  44337. /** @hidden */
  44338. export var backgroundPixelShader: {
  44339. name: string;
  44340. shader: string;
  44341. };
  44342. }
  44343. declare module BABYLON {
  44344. /** @hidden */
  44345. export var backgroundVertexDeclaration: {
  44346. name: string;
  44347. shader: string;
  44348. };
  44349. }
  44350. declare module BABYLON {
  44351. /** @hidden */
  44352. export var backgroundVertexShader: {
  44353. name: string;
  44354. shader: string;
  44355. };
  44356. }
  44357. declare module BABYLON {
  44358. /**
  44359. * Background material used to create an efficient environement around your scene.
  44360. */
  44361. export class BackgroundMaterial extends PushMaterial {
  44362. /**
  44363. * Standard reflectance value at parallel view angle.
  44364. */
  44365. static StandardReflectance0: number;
  44366. /**
  44367. * Standard reflectance value at grazing angle.
  44368. */
  44369. static StandardReflectance90: number;
  44370. protected _primaryColor: Color3;
  44371. /**
  44372. * Key light Color (multiply against the environement texture)
  44373. */
  44374. primaryColor: Color3;
  44375. protected __perceptualColor: Nullable<Color3>;
  44376. /**
  44377. * Experimental Internal Use Only.
  44378. *
  44379. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44380. * This acts as a helper to set the primary color to a more "human friendly" value.
  44381. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44382. * output color as close as possible from the chosen value.
  44383. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44384. * part of lighting setup.)
  44385. */
  44386. _perceptualColor: Nullable<Color3>;
  44387. protected _primaryColorShadowLevel: float;
  44388. /**
  44389. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44390. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44391. */
  44392. primaryColorShadowLevel: float;
  44393. protected _primaryColorHighlightLevel: float;
  44394. /**
  44395. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44396. * The primary color is used at the level chosen to define what the white area would look.
  44397. */
  44398. primaryColorHighlightLevel: float;
  44399. protected _reflectionTexture: Nullable<BaseTexture>;
  44400. /**
  44401. * Reflection Texture used in the material.
  44402. * Should be author in a specific way for the best result (refer to the documentation).
  44403. */
  44404. reflectionTexture: Nullable<BaseTexture>;
  44405. protected _reflectionBlur: float;
  44406. /**
  44407. * Reflection Texture level of blur.
  44408. *
  44409. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44410. * texture twice.
  44411. */
  44412. reflectionBlur: float;
  44413. protected _diffuseTexture: Nullable<BaseTexture>;
  44414. /**
  44415. * Diffuse Texture used in the material.
  44416. * Should be author in a specific way for the best result (refer to the documentation).
  44417. */
  44418. diffuseTexture: Nullable<BaseTexture>;
  44419. protected _shadowLights: Nullable<IShadowLight[]>;
  44420. /**
  44421. * Specify the list of lights casting shadow on the material.
  44422. * All scene shadow lights will be included if null.
  44423. */
  44424. shadowLights: Nullable<IShadowLight[]>;
  44425. protected _shadowLevel: float;
  44426. /**
  44427. * Helps adjusting the shadow to a softer level if required.
  44428. * 0 means black shadows and 1 means no shadows.
  44429. */
  44430. shadowLevel: float;
  44431. protected _sceneCenter: Vector3;
  44432. /**
  44433. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44434. * It is usually zero but might be interesting to modify according to your setup.
  44435. */
  44436. sceneCenter: Vector3;
  44437. protected _opacityFresnel: boolean;
  44438. /**
  44439. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44440. * This helps ensuring a nice transition when the camera goes under the ground.
  44441. */
  44442. opacityFresnel: boolean;
  44443. protected _reflectionFresnel: boolean;
  44444. /**
  44445. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44446. * This helps adding a mirror texture on the ground.
  44447. */
  44448. reflectionFresnel: boolean;
  44449. protected _reflectionFalloffDistance: number;
  44450. /**
  44451. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44452. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44453. */
  44454. reflectionFalloffDistance: number;
  44455. protected _reflectionAmount: number;
  44456. /**
  44457. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44458. */
  44459. reflectionAmount: number;
  44460. protected _reflectionReflectance0: number;
  44461. /**
  44462. * This specifies the weight of the reflection at grazing angle.
  44463. */
  44464. reflectionReflectance0: number;
  44465. protected _reflectionReflectance90: number;
  44466. /**
  44467. * This specifies the weight of the reflection at a perpendicular point of view.
  44468. */
  44469. reflectionReflectance90: number;
  44470. /**
  44471. * Sets the reflection reflectance fresnel values according to the default standard
  44472. * empirically know to work well :-)
  44473. */
  44474. reflectionStandardFresnelWeight: number;
  44475. protected _useRGBColor: boolean;
  44476. /**
  44477. * Helps to directly use the maps channels instead of their level.
  44478. */
  44479. useRGBColor: boolean;
  44480. protected _enableNoise: boolean;
  44481. /**
  44482. * This helps reducing the banding effect that could occur on the background.
  44483. */
  44484. enableNoise: boolean;
  44485. /**
  44486. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44487. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44488. * Recommended to be keep at 1.0 except for special cases.
  44489. */
  44490. fovMultiplier: number;
  44491. private _fovMultiplier;
  44492. /**
  44493. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44494. */
  44495. useEquirectangularFOV: boolean;
  44496. private _maxSimultaneousLights;
  44497. /**
  44498. * Number of Simultaneous lights allowed on the material.
  44499. */
  44500. maxSimultaneousLights: int;
  44501. /**
  44502. * Default configuration related to image processing available in the Background Material.
  44503. */
  44504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44505. /**
  44506. * Keep track of the image processing observer to allow dispose and replace.
  44507. */
  44508. private _imageProcessingObserver;
  44509. /**
  44510. * Attaches a new image processing configuration to the PBR Material.
  44511. * @param configuration (if null the scene configuration will be use)
  44512. */
  44513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44514. /**
  44515. * Gets the image processing configuration used either in this material.
  44516. */
  44517. /**
  44518. * Sets the Default image processing configuration used either in the this material.
  44519. *
  44520. * If sets to null, the scene one is in use.
  44521. */
  44522. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44523. /**
  44524. * Gets wether the color curves effect is enabled.
  44525. */
  44526. /**
  44527. * Sets wether the color curves effect is enabled.
  44528. */
  44529. cameraColorCurvesEnabled: boolean;
  44530. /**
  44531. * Gets wether the color grading effect is enabled.
  44532. */
  44533. /**
  44534. * Gets wether the color grading effect is enabled.
  44535. */
  44536. cameraColorGradingEnabled: boolean;
  44537. /**
  44538. * Gets wether tonemapping is enabled or not.
  44539. */
  44540. /**
  44541. * Sets wether tonemapping is enabled or not
  44542. */
  44543. cameraToneMappingEnabled: boolean;
  44544. /**
  44545. * The camera exposure used on this material.
  44546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44547. * This corresponds to a photographic exposure.
  44548. */
  44549. /**
  44550. * The camera exposure used on this material.
  44551. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44552. * This corresponds to a photographic exposure.
  44553. */
  44554. cameraExposure: float;
  44555. /**
  44556. * Gets The camera contrast used on this material.
  44557. */
  44558. /**
  44559. * Sets The camera contrast used on this material.
  44560. */
  44561. cameraContrast: float;
  44562. /**
  44563. * Gets the Color Grading 2D Lookup Texture.
  44564. */
  44565. /**
  44566. * Sets the Color Grading 2D Lookup Texture.
  44567. */
  44568. cameraColorGradingTexture: Nullable<BaseTexture>;
  44569. /**
  44570. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44571. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44572. * 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;
  44573. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44574. */
  44575. /**
  44576. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44577. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44578. * 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;
  44579. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44580. */
  44581. cameraColorCurves: Nullable<ColorCurves>;
  44582. /**
  44583. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44584. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44585. */
  44586. switchToBGR: boolean;
  44587. private _renderTargets;
  44588. private _reflectionControls;
  44589. private _white;
  44590. private _primaryShadowColor;
  44591. private _primaryHighlightColor;
  44592. /**
  44593. * Instantiates a Background Material in the given scene
  44594. * @param name The friendly name of the material
  44595. * @param scene The scene to add the material to
  44596. */
  44597. constructor(name: string, scene: Scene);
  44598. /**
  44599. * Gets a boolean indicating that current material needs to register RTT
  44600. */
  44601. readonly hasRenderTargetTextures: boolean;
  44602. /**
  44603. * The entire material has been created in order to prevent overdraw.
  44604. * @returns false
  44605. */
  44606. needAlphaTesting(): boolean;
  44607. /**
  44608. * The entire material has been created in order to prevent overdraw.
  44609. * @returns true if blending is enable
  44610. */
  44611. needAlphaBlending(): boolean;
  44612. /**
  44613. * Checks wether the material is ready to be rendered for a given mesh.
  44614. * @param mesh The mesh to render
  44615. * @param subMesh The submesh to check against
  44616. * @param useInstances Specify wether or not the material is used with instances
  44617. * @returns true if all the dependencies are ready (Textures, Effects...)
  44618. */
  44619. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44620. /**
  44621. * Compute the primary color according to the chosen perceptual color.
  44622. */
  44623. private _computePrimaryColorFromPerceptualColor;
  44624. /**
  44625. * Compute the highlights and shadow colors according to their chosen levels.
  44626. */
  44627. private _computePrimaryColors;
  44628. /**
  44629. * Build the uniform buffer used in the material.
  44630. */
  44631. buildUniformLayout(): void;
  44632. /**
  44633. * Unbind the material.
  44634. */
  44635. unbind(): void;
  44636. /**
  44637. * Bind only the world matrix to the material.
  44638. * @param world The world matrix to bind.
  44639. */
  44640. bindOnlyWorldMatrix(world: Matrix): void;
  44641. /**
  44642. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44643. * @param world The world matrix to bind.
  44644. * @param subMesh The submesh to bind for.
  44645. */
  44646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44647. /**
  44648. * Dispose the material.
  44649. * @param forceDisposeEffect Force disposal of the associated effect.
  44650. * @param forceDisposeTextures Force disposal of the associated textures.
  44651. */
  44652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44653. /**
  44654. * Clones the material.
  44655. * @param name The cloned name.
  44656. * @returns The cloned material.
  44657. */
  44658. clone(name: string): BackgroundMaterial;
  44659. /**
  44660. * Serializes the current material to its JSON representation.
  44661. * @returns The JSON representation.
  44662. */
  44663. serialize(): any;
  44664. /**
  44665. * Gets the class name of the material
  44666. * @returns "BackgroundMaterial"
  44667. */
  44668. getClassName(): string;
  44669. /**
  44670. * Parse a JSON input to create back a background material.
  44671. * @param source The JSON data to parse
  44672. * @param scene The scene to create the parsed material in
  44673. * @param rootUrl The root url of the assets the material depends upon
  44674. * @returns the instantiated BackgroundMaterial.
  44675. */
  44676. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44677. }
  44678. }
  44679. declare module BABYLON {
  44680. /**
  44681. * Represents the different options available during the creation of
  44682. * a Environment helper.
  44683. *
  44684. * This can control the default ground, skybox and image processing setup of your scene.
  44685. */
  44686. export interface IEnvironmentHelperOptions {
  44687. /**
  44688. * Specifies wether or not to create a ground.
  44689. * True by default.
  44690. */
  44691. createGround: boolean;
  44692. /**
  44693. * Specifies the ground size.
  44694. * 15 by default.
  44695. */
  44696. groundSize: number;
  44697. /**
  44698. * The texture used on the ground for the main color.
  44699. * Comes from the BabylonJS CDN by default.
  44700. *
  44701. * Remarks: Can be either a texture or a url.
  44702. */
  44703. groundTexture: string | BaseTexture;
  44704. /**
  44705. * The color mixed in the ground texture by default.
  44706. * BabylonJS clearColor by default.
  44707. */
  44708. groundColor: Color3;
  44709. /**
  44710. * Specifies the ground opacity.
  44711. * 1 by default.
  44712. */
  44713. groundOpacity: number;
  44714. /**
  44715. * Enables the ground to receive shadows.
  44716. * True by default.
  44717. */
  44718. enableGroundShadow: boolean;
  44719. /**
  44720. * Helps preventing the shadow to be fully black on the ground.
  44721. * 0.5 by default.
  44722. */
  44723. groundShadowLevel: number;
  44724. /**
  44725. * Creates a mirror texture attach to the ground.
  44726. * false by default.
  44727. */
  44728. enableGroundMirror: boolean;
  44729. /**
  44730. * Specifies the ground mirror size ratio.
  44731. * 0.3 by default as the default kernel is 64.
  44732. */
  44733. groundMirrorSizeRatio: number;
  44734. /**
  44735. * Specifies the ground mirror blur kernel size.
  44736. * 64 by default.
  44737. */
  44738. groundMirrorBlurKernel: number;
  44739. /**
  44740. * Specifies the ground mirror visibility amount.
  44741. * 1 by default
  44742. */
  44743. groundMirrorAmount: number;
  44744. /**
  44745. * Specifies the ground mirror reflectance weight.
  44746. * This uses the standard weight of the background material to setup the fresnel effect
  44747. * of the mirror.
  44748. * 1 by default.
  44749. */
  44750. groundMirrorFresnelWeight: number;
  44751. /**
  44752. * Specifies the ground mirror Falloff distance.
  44753. * This can helps reducing the size of the reflection.
  44754. * 0 by Default.
  44755. */
  44756. groundMirrorFallOffDistance: number;
  44757. /**
  44758. * Specifies the ground mirror texture type.
  44759. * Unsigned Int by Default.
  44760. */
  44761. groundMirrorTextureType: number;
  44762. /**
  44763. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44764. * the shown objects.
  44765. */
  44766. groundYBias: number;
  44767. /**
  44768. * Specifies wether or not to create a skybox.
  44769. * True by default.
  44770. */
  44771. createSkybox: boolean;
  44772. /**
  44773. * Specifies the skybox size.
  44774. * 20 by default.
  44775. */
  44776. skyboxSize: number;
  44777. /**
  44778. * The texture used on the skybox for the main color.
  44779. * Comes from the BabylonJS CDN by default.
  44780. *
  44781. * Remarks: Can be either a texture or a url.
  44782. */
  44783. skyboxTexture: string | BaseTexture;
  44784. /**
  44785. * The color mixed in the skybox texture by default.
  44786. * BabylonJS clearColor by default.
  44787. */
  44788. skyboxColor: Color3;
  44789. /**
  44790. * The background rotation around the Y axis of the scene.
  44791. * This helps aligning the key lights of your scene with the background.
  44792. * 0 by default.
  44793. */
  44794. backgroundYRotation: number;
  44795. /**
  44796. * Compute automatically the size of the elements to best fit with the scene.
  44797. */
  44798. sizeAuto: boolean;
  44799. /**
  44800. * Default position of the rootMesh if autoSize is not true.
  44801. */
  44802. rootPosition: Vector3;
  44803. /**
  44804. * Sets up the image processing in the scene.
  44805. * true by default.
  44806. */
  44807. setupImageProcessing: boolean;
  44808. /**
  44809. * The texture used as your environment texture in the scene.
  44810. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44811. *
  44812. * Remarks: Can be either a texture or a url.
  44813. */
  44814. environmentTexture: string | BaseTexture;
  44815. /**
  44816. * The value of the exposure to apply to the scene.
  44817. * 0.6 by default if setupImageProcessing is true.
  44818. */
  44819. cameraExposure: number;
  44820. /**
  44821. * The value of the contrast to apply to the scene.
  44822. * 1.6 by default if setupImageProcessing is true.
  44823. */
  44824. cameraContrast: number;
  44825. /**
  44826. * Specifies wether or not tonemapping should be enabled in the scene.
  44827. * true by default if setupImageProcessing is true.
  44828. */
  44829. toneMappingEnabled: boolean;
  44830. }
  44831. /**
  44832. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44833. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44834. * It also helps with the default setup of your imageProcessing configuration.
  44835. */
  44836. export class EnvironmentHelper {
  44837. /**
  44838. * Default ground texture URL.
  44839. */
  44840. private static _groundTextureCDNUrl;
  44841. /**
  44842. * Default skybox texture URL.
  44843. */
  44844. private static _skyboxTextureCDNUrl;
  44845. /**
  44846. * Default environment texture URL.
  44847. */
  44848. private static _environmentTextureCDNUrl;
  44849. /**
  44850. * Creates the default options for the helper.
  44851. */
  44852. private static _getDefaultOptions;
  44853. private _rootMesh;
  44854. /**
  44855. * Gets the root mesh created by the helper.
  44856. */
  44857. readonly rootMesh: Mesh;
  44858. private _skybox;
  44859. /**
  44860. * Gets the skybox created by the helper.
  44861. */
  44862. readonly skybox: Nullable<Mesh>;
  44863. private _skyboxTexture;
  44864. /**
  44865. * Gets the skybox texture created by the helper.
  44866. */
  44867. readonly skyboxTexture: Nullable<BaseTexture>;
  44868. private _skyboxMaterial;
  44869. /**
  44870. * Gets the skybox material created by the helper.
  44871. */
  44872. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44873. private _ground;
  44874. /**
  44875. * Gets the ground mesh created by the helper.
  44876. */
  44877. readonly ground: Nullable<Mesh>;
  44878. private _groundTexture;
  44879. /**
  44880. * Gets the ground texture created by the helper.
  44881. */
  44882. readonly groundTexture: Nullable<BaseTexture>;
  44883. private _groundMirror;
  44884. /**
  44885. * Gets the ground mirror created by the helper.
  44886. */
  44887. readonly groundMirror: Nullable<MirrorTexture>;
  44888. /**
  44889. * Gets the ground mirror render list to helps pushing the meshes
  44890. * you wish in the ground reflection.
  44891. */
  44892. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44893. private _groundMaterial;
  44894. /**
  44895. * Gets the ground material created by the helper.
  44896. */
  44897. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44898. /**
  44899. * Stores the creation options.
  44900. */
  44901. private readonly _scene;
  44902. private _options;
  44903. /**
  44904. * This observable will be notified with any error during the creation of the environment,
  44905. * mainly texture creation errors.
  44906. */
  44907. onErrorObservable: Observable<{
  44908. message?: string;
  44909. exception?: any;
  44910. }>;
  44911. /**
  44912. * constructor
  44913. * @param options Defines the options we want to customize the helper
  44914. * @param scene The scene to add the material to
  44915. */
  44916. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44917. /**
  44918. * Updates the background according to the new options
  44919. * @param options
  44920. */
  44921. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44922. /**
  44923. * Sets the primary color of all the available elements.
  44924. * @param color the main color to affect to the ground and the background
  44925. */
  44926. setMainColor(color: Color3): void;
  44927. /**
  44928. * Setup the image processing according to the specified options.
  44929. */
  44930. private _setupImageProcessing;
  44931. /**
  44932. * Setup the environment texture according to the specified options.
  44933. */
  44934. private _setupEnvironmentTexture;
  44935. /**
  44936. * Setup the background according to the specified options.
  44937. */
  44938. private _setupBackground;
  44939. /**
  44940. * Get the scene sizes according to the setup.
  44941. */
  44942. private _getSceneSize;
  44943. /**
  44944. * Setup the ground according to the specified options.
  44945. */
  44946. private _setupGround;
  44947. /**
  44948. * Setup the ground material according to the specified options.
  44949. */
  44950. private _setupGroundMaterial;
  44951. /**
  44952. * Setup the ground diffuse texture according to the specified options.
  44953. */
  44954. private _setupGroundDiffuseTexture;
  44955. /**
  44956. * Setup the ground mirror texture according to the specified options.
  44957. */
  44958. private _setupGroundMirrorTexture;
  44959. /**
  44960. * Setup the ground to receive the mirror texture.
  44961. */
  44962. private _setupMirrorInGroundMaterial;
  44963. /**
  44964. * Setup the skybox according to the specified options.
  44965. */
  44966. private _setupSkybox;
  44967. /**
  44968. * Setup the skybox material according to the specified options.
  44969. */
  44970. private _setupSkyboxMaterial;
  44971. /**
  44972. * Setup the skybox reflection texture according to the specified options.
  44973. */
  44974. private _setupSkyboxReflectionTexture;
  44975. private _errorHandler;
  44976. /**
  44977. * Dispose all the elements created by the Helper.
  44978. */
  44979. dispose(): void;
  44980. }
  44981. }
  44982. declare module BABYLON {
  44983. /**
  44984. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44985. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44986. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44987. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44988. */
  44989. export class PhotoDome extends TransformNode {
  44990. /**
  44991. * Define the image as a Monoscopic panoramic 360 image.
  44992. */
  44993. static readonly MODE_MONOSCOPIC: number;
  44994. /**
  44995. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44996. */
  44997. static readonly MODE_TOPBOTTOM: number;
  44998. /**
  44999. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45000. */
  45001. static readonly MODE_SIDEBYSIDE: number;
  45002. private _useDirectMapping;
  45003. /**
  45004. * The texture being displayed on the sphere
  45005. */
  45006. protected _photoTexture: Texture;
  45007. /**
  45008. * Gets or sets the texture being displayed on the sphere
  45009. */
  45010. photoTexture: Texture;
  45011. /**
  45012. * Observable raised when an error occured while loading the 360 image
  45013. */
  45014. onLoadErrorObservable: Observable<string>;
  45015. /**
  45016. * The skybox material
  45017. */
  45018. protected _material: BackgroundMaterial;
  45019. /**
  45020. * The surface used for the skybox
  45021. */
  45022. protected _mesh: Mesh;
  45023. /**
  45024. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45025. * Also see the options.resolution property.
  45026. */
  45027. fovMultiplier: number;
  45028. private _imageMode;
  45029. /**
  45030. * Gets or set the current video mode for the video. It can be:
  45031. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45032. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45033. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45034. */
  45035. imageMode: number;
  45036. /**
  45037. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45038. * @param name Element's name, child elements will append suffixes for their own names.
  45039. * @param urlsOfPhoto defines the url of the photo to display
  45040. * @param options defines an object containing optional or exposed sub element properties
  45041. * @param onError defines a callback called when an error occured while loading the texture
  45042. */
  45043. constructor(name: string, urlOfPhoto: string, options: {
  45044. resolution?: number;
  45045. size?: number;
  45046. useDirectMapping?: boolean;
  45047. faceForward?: boolean;
  45048. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45049. private _onBeforeCameraRenderObserver;
  45050. private _changeImageMode;
  45051. /**
  45052. * Releases resources associated with this node.
  45053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45055. */
  45056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45057. }
  45058. }
  45059. declare module BABYLON {
  45060. /** @hidden */
  45061. export var rgbdDecodePixelShader: {
  45062. name: string;
  45063. shader: string;
  45064. };
  45065. }
  45066. declare module BABYLON {
  45067. /**
  45068. * Class used to host texture specific utilities
  45069. */
  45070. export class BRDFTextureTools {
  45071. /**
  45072. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45073. * @param texture the texture to expand.
  45074. */
  45075. private static _ExpandDefaultBRDFTexture;
  45076. /**
  45077. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45078. * @param scene defines the hosting scene
  45079. * @returns the environment BRDF texture
  45080. */
  45081. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45082. private static _environmentBRDFBase64Texture;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /**
  45087. * @hidden
  45088. */
  45089. export interface IMaterialClearCoatDefines {
  45090. CLEARCOAT: boolean;
  45091. CLEARCOAT_DEFAULTIOR: boolean;
  45092. CLEARCOAT_TEXTURE: boolean;
  45093. CLEARCOAT_TEXTUREDIRECTUV: number;
  45094. CLEARCOAT_BUMP: boolean;
  45095. CLEARCOAT_BUMPDIRECTUV: number;
  45096. CLEARCOAT_TINT: boolean;
  45097. CLEARCOAT_TINT_TEXTURE: boolean;
  45098. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45099. /** @hidden */
  45100. _areTexturesDirty: boolean;
  45101. }
  45102. /**
  45103. * Define the code related to the clear coat parameters of the pbr material.
  45104. */
  45105. export class PBRClearCoatConfiguration {
  45106. /**
  45107. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45108. * The default fits with a polyurethane material.
  45109. */
  45110. private static readonly _DefaultIndexOfRefraction;
  45111. private _isEnabled;
  45112. /**
  45113. * Defines if the clear coat is enabled in the material.
  45114. */
  45115. isEnabled: boolean;
  45116. /**
  45117. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45118. */
  45119. intensity: number;
  45120. /**
  45121. * Defines the clear coat layer roughness.
  45122. */
  45123. roughness: number;
  45124. private _indexOfRefraction;
  45125. /**
  45126. * Defines the index of refraction of the clear coat.
  45127. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45128. * The default fits with a polyurethane material.
  45129. * Changing the default value is more performance intensive.
  45130. */
  45131. indexOfRefraction: number;
  45132. private _texture;
  45133. /**
  45134. * Stores the clear coat values in a texture.
  45135. */
  45136. texture: Nullable<BaseTexture>;
  45137. private _bumpTexture;
  45138. /**
  45139. * Define the clear coat specific bump texture.
  45140. */
  45141. bumpTexture: Nullable<BaseTexture>;
  45142. private _isTintEnabled;
  45143. /**
  45144. * Defines if the clear coat tint is enabled in the material.
  45145. */
  45146. isTintEnabled: boolean;
  45147. /**
  45148. * Defines the clear coat tint of the material.
  45149. * This is only use if tint is enabled
  45150. */
  45151. tintColor: Color3;
  45152. /**
  45153. * Defines the distance at which the tint color should be found in the
  45154. * clear coat media.
  45155. * This is only use if tint is enabled
  45156. */
  45157. tintColorAtDistance: number;
  45158. /**
  45159. * Defines the clear coat layer thickness.
  45160. * This is only use if tint is enabled
  45161. */
  45162. tintThickness: number;
  45163. private _tintTexture;
  45164. /**
  45165. * Stores the clear tint values in a texture.
  45166. * rgb is tint
  45167. * a is a thickness factor
  45168. */
  45169. tintTexture: Nullable<BaseTexture>;
  45170. /** @hidden */
  45171. private _internalMarkAllSubMeshesAsTexturesDirty;
  45172. /** @hidden */
  45173. _markAllSubMeshesAsTexturesDirty(): void;
  45174. /**
  45175. * Instantiate a new istance of clear coat configuration.
  45176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45177. */
  45178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45179. /**
  45180. * Gets wehter the submesh is ready to be used or not.
  45181. * @param defines the list of "defines" to update.
  45182. * @param scene defines the scene the material belongs to.
  45183. * @param engine defines the engine the material belongs to.
  45184. * @param disableBumpMap defines wether the material disables bump or not.
  45185. * @returns - boolean indicating that the submesh is ready or not.
  45186. */
  45187. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45188. /**
  45189. * Checks to see if a texture is used in the material.
  45190. * @param defines the list of "defines" to update.
  45191. * @param scene defines the scene to the material belongs to.
  45192. */
  45193. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45194. /**
  45195. * Binds the material data.
  45196. * @param uniformBuffer defines the Uniform buffer to fill in.
  45197. * @param scene defines the scene the material belongs to.
  45198. * @param engine defines the engine the material belongs to.
  45199. * @param disableBumpMap defines wether the material disables bump or not.
  45200. * @param isFrozen defines wether the material is frozen or not.
  45201. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45202. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45203. */
  45204. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45205. /**
  45206. * Checks to see if a texture is used in the material.
  45207. * @param texture - Base texture to use.
  45208. * @returns - Boolean specifying if a texture is used in the material.
  45209. */
  45210. hasTexture(texture: BaseTexture): boolean;
  45211. /**
  45212. * Returns an array of the actively used textures.
  45213. * @param activeTextures Array of BaseTextures
  45214. */
  45215. getActiveTextures(activeTextures: BaseTexture[]): void;
  45216. /**
  45217. * Returns the animatable textures.
  45218. * @param animatables Array of animatable textures.
  45219. */
  45220. getAnimatables(animatables: IAnimatable[]): void;
  45221. /**
  45222. * Disposes the resources of the material.
  45223. * @param forceDisposeTextures - Forces the disposal of all textures.
  45224. */
  45225. dispose(forceDisposeTextures?: boolean): void;
  45226. /**
  45227. * Get the current class name of the texture useful for serialization or dynamic coding.
  45228. * @returns "PBRClearCoatConfiguration"
  45229. */
  45230. getClassName(): string;
  45231. /**
  45232. * Add fallbacks to the effect fallbacks list.
  45233. * @param defines defines the Base texture to use.
  45234. * @param fallbacks defines the current fallback list.
  45235. * @param currentRank defines the current fallback rank.
  45236. * @returns the new fallback rank.
  45237. */
  45238. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45239. /**
  45240. * Add the required uniforms to the current list.
  45241. * @param uniforms defines the current uniform list.
  45242. */
  45243. static AddUniforms(uniforms: string[]): void;
  45244. /**
  45245. * Add the required samplers to the current list.
  45246. * @param samplers defines the current sampler list.
  45247. */
  45248. static AddSamplers(samplers: string[]): void;
  45249. /**
  45250. * Add the required uniforms to the current buffer.
  45251. * @param uniformBuffer defines the current uniform buffer.
  45252. */
  45253. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45254. /**
  45255. * Makes a duplicate of the current configuration into another one.
  45256. * @param clearCoatConfiguration define the config where to copy the info
  45257. */
  45258. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45259. /**
  45260. * Serializes this clear coat configuration.
  45261. * @returns - An object with the serialized config.
  45262. */
  45263. serialize(): any;
  45264. /**
  45265. * Parses a anisotropy Configuration from a serialized object.
  45266. * @param source - Serialized object.
  45267. * @param scene Defines the scene we are parsing for
  45268. * @param rootUrl Defines the rootUrl to load from
  45269. */
  45270. parse(source: any, scene: Scene, rootUrl: string): void;
  45271. }
  45272. }
  45273. declare module BABYLON {
  45274. /**
  45275. * @hidden
  45276. */
  45277. export interface IMaterialAnisotropicDefines {
  45278. ANISOTROPIC: boolean;
  45279. ANISOTROPIC_TEXTURE: boolean;
  45280. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45281. MAINUV1: boolean;
  45282. _areTexturesDirty: boolean;
  45283. _needUVs: boolean;
  45284. }
  45285. /**
  45286. * Define the code related to the anisotropic parameters of the pbr material.
  45287. */
  45288. export class PBRAnisotropicConfiguration {
  45289. private _isEnabled;
  45290. /**
  45291. * Defines if the anisotropy is enabled in the material.
  45292. */
  45293. isEnabled: boolean;
  45294. /**
  45295. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45296. */
  45297. intensity: number;
  45298. /**
  45299. * Defines if the effect is along the tangents, bitangents or in between.
  45300. * By default, the effect is "strectching" the highlights along the tangents.
  45301. */
  45302. direction: Vector2;
  45303. private _texture;
  45304. /**
  45305. * Stores the anisotropy values in a texture.
  45306. * rg is direction (like normal from -1 to 1)
  45307. * b is a intensity
  45308. */
  45309. texture: Nullable<BaseTexture>;
  45310. /** @hidden */
  45311. private _internalMarkAllSubMeshesAsTexturesDirty;
  45312. /** @hidden */
  45313. _markAllSubMeshesAsTexturesDirty(): void;
  45314. /**
  45315. * Instantiate a new istance of anisotropy configuration.
  45316. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45317. */
  45318. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45319. /**
  45320. * Specifies that the submesh is ready to be used.
  45321. * @param defines the list of "defines" to update.
  45322. * @param scene defines the scene the material belongs to.
  45323. * @returns - boolean indicating that the submesh is ready or not.
  45324. */
  45325. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45326. /**
  45327. * Checks to see if a texture is used in the material.
  45328. * @param defines the list of "defines" to update.
  45329. * @param mesh the mesh we are preparing the defines for.
  45330. * @param scene defines the scene the material belongs to.
  45331. */
  45332. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45333. /**
  45334. * Binds the material data.
  45335. * @param uniformBuffer defines the Uniform buffer to fill in.
  45336. * @param scene defines the scene the material belongs to.
  45337. * @param isFrozen defines wether the material is frozen or not.
  45338. */
  45339. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45340. /**
  45341. * Checks to see if a texture is used in the material.
  45342. * @param texture - Base texture to use.
  45343. * @returns - Boolean specifying if a texture is used in the material.
  45344. */
  45345. hasTexture(texture: BaseTexture): boolean;
  45346. /**
  45347. * Returns an array of the actively used textures.
  45348. * @param activeTextures Array of BaseTextures
  45349. */
  45350. getActiveTextures(activeTextures: BaseTexture[]): void;
  45351. /**
  45352. * Returns the animatable textures.
  45353. * @param animatables Array of animatable textures.
  45354. */
  45355. getAnimatables(animatables: IAnimatable[]): void;
  45356. /**
  45357. * Disposes the resources of the material.
  45358. * @param forceDisposeTextures - Forces the disposal of all textures.
  45359. */
  45360. dispose(forceDisposeTextures?: boolean): void;
  45361. /**
  45362. * Get the current class name of the texture useful for serialization or dynamic coding.
  45363. * @returns "PBRAnisotropicConfiguration"
  45364. */
  45365. getClassName(): string;
  45366. /**
  45367. * Add fallbacks to the effect fallbacks list.
  45368. * @param defines defines the Base texture to use.
  45369. * @param fallbacks defines the current fallback list.
  45370. * @param currentRank defines the current fallback rank.
  45371. * @returns the new fallback rank.
  45372. */
  45373. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45374. /**
  45375. * Add the required uniforms to the current list.
  45376. * @param uniforms defines the current uniform list.
  45377. */
  45378. static AddUniforms(uniforms: string[]): void;
  45379. /**
  45380. * Add the required uniforms to the current buffer.
  45381. * @param uniformBuffer defines the current uniform buffer.
  45382. */
  45383. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45384. /**
  45385. * Add the required samplers to the current list.
  45386. * @param samplers defines the current sampler list.
  45387. */
  45388. static AddSamplers(samplers: string[]): void;
  45389. /**
  45390. * Makes a duplicate of the current configuration into another one.
  45391. * @param anisotropicConfiguration define the config where to copy the info
  45392. */
  45393. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45394. /**
  45395. * Serializes this anisotropy configuration.
  45396. * @returns - An object with the serialized config.
  45397. */
  45398. serialize(): any;
  45399. /**
  45400. * Parses a anisotropy Configuration from a serialized object.
  45401. * @param source - Serialized object.
  45402. * @param scene Defines the scene we are parsing for
  45403. * @param rootUrl Defines the rootUrl to load from
  45404. */
  45405. parse(source: any, scene: Scene, rootUrl: string): void;
  45406. }
  45407. }
  45408. declare module BABYLON {
  45409. /**
  45410. * @hidden
  45411. */
  45412. export interface IMaterialBRDFDefines {
  45413. BRDF_V_HEIGHT_CORRELATED: boolean;
  45414. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45415. SPHERICAL_HARMONICS: boolean;
  45416. /** @hidden */
  45417. _areMiscDirty: boolean;
  45418. }
  45419. /**
  45420. * Define the code related to the BRDF parameters of the pbr material.
  45421. */
  45422. export class PBRBRDFConfiguration {
  45423. /**
  45424. * Default value used for the energy conservation.
  45425. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45426. */
  45427. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45428. /**
  45429. * Default value used for the Smith Visibility Height Correlated mode.
  45430. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45431. */
  45432. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45433. /**
  45434. * Default value used for the IBL diffuse part.
  45435. * This can help switching back to the polynomials mode globally which is a tiny bit
  45436. * less GPU intensive at the drawback of a lower quality.
  45437. */
  45438. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45439. private _useEnergyConservation;
  45440. /**
  45441. * Defines if the material uses energy conservation.
  45442. */
  45443. useEnergyConservation: boolean;
  45444. private _useSmithVisibilityHeightCorrelated;
  45445. /**
  45446. * LEGACY Mode set to false
  45447. * Defines if the material uses height smith correlated visibility term.
  45448. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45449. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45450. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45451. * Not relying on height correlated will also disable energy conservation.
  45452. */
  45453. useSmithVisibilityHeightCorrelated: boolean;
  45454. private _useSphericalHarmonics;
  45455. /**
  45456. * LEGACY Mode set to false
  45457. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45458. * diffuse part of the IBL.
  45459. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45460. * to the ground truth.
  45461. */
  45462. useSphericalHarmonics: boolean;
  45463. /** @hidden */
  45464. private _internalMarkAllSubMeshesAsMiscDirty;
  45465. /** @hidden */
  45466. _markAllSubMeshesAsMiscDirty(): void;
  45467. /**
  45468. * Instantiate a new istance of clear coat configuration.
  45469. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45470. */
  45471. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45472. /**
  45473. * Checks to see if a texture is used in the material.
  45474. * @param defines the list of "defines" to update.
  45475. */
  45476. prepareDefines(defines: IMaterialBRDFDefines): void;
  45477. /**
  45478. * Get the current class name of the texture useful for serialization or dynamic coding.
  45479. * @returns "PBRClearCoatConfiguration"
  45480. */
  45481. getClassName(): string;
  45482. /**
  45483. * Makes a duplicate of the current configuration into another one.
  45484. * @param brdfConfiguration define the config where to copy the info
  45485. */
  45486. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45487. /**
  45488. * Serializes this BRDF configuration.
  45489. * @returns - An object with the serialized config.
  45490. */
  45491. serialize(): any;
  45492. /**
  45493. * Parses a anisotropy Configuration from a serialized object.
  45494. * @param source - Serialized object.
  45495. * @param scene Defines the scene we are parsing for
  45496. * @param rootUrl Defines the rootUrl to load from
  45497. */
  45498. parse(source: any, scene: Scene, rootUrl: string): void;
  45499. }
  45500. }
  45501. declare module BABYLON {
  45502. /**
  45503. * @hidden
  45504. */
  45505. export interface IMaterialSheenDefines {
  45506. SHEEN: boolean;
  45507. SHEEN_TEXTURE: boolean;
  45508. SHEEN_TEXTUREDIRECTUV: number;
  45509. SHEEN_LINKWITHALBEDO: boolean;
  45510. /** @hidden */
  45511. _areTexturesDirty: boolean;
  45512. }
  45513. /**
  45514. * Define the code related to the Sheen parameters of the pbr material.
  45515. */
  45516. export class PBRSheenConfiguration {
  45517. private _isEnabled;
  45518. /**
  45519. * Defines if the material uses sheen.
  45520. */
  45521. isEnabled: boolean;
  45522. private _linkSheenWithAlbedo;
  45523. /**
  45524. * Defines if the sheen is linked to the sheen color.
  45525. */
  45526. linkSheenWithAlbedo: boolean;
  45527. /**
  45528. * Defines the sheen intensity.
  45529. */
  45530. intensity: number;
  45531. /**
  45532. * Defines the sheen color.
  45533. */
  45534. color: Color3;
  45535. private _texture;
  45536. /**
  45537. * Stores the sheen tint values in a texture.
  45538. * rgb is tint
  45539. * a is a intensity
  45540. */
  45541. texture: Nullable<BaseTexture>;
  45542. /** @hidden */
  45543. private _internalMarkAllSubMeshesAsTexturesDirty;
  45544. /** @hidden */
  45545. _markAllSubMeshesAsTexturesDirty(): void;
  45546. /**
  45547. * Instantiate a new istance of clear coat configuration.
  45548. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45549. */
  45550. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45551. /**
  45552. * Specifies that the submesh is ready to be used.
  45553. * @param defines the list of "defines" to update.
  45554. * @param scene defines the scene the material belongs to.
  45555. * @returns - boolean indicating that the submesh is ready or not.
  45556. */
  45557. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45558. /**
  45559. * Checks to see if a texture is used in the material.
  45560. * @param defines the list of "defines" to update.
  45561. * @param scene defines the scene the material belongs to.
  45562. */
  45563. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45564. /**
  45565. * Binds the material data.
  45566. * @param uniformBuffer defines the Uniform buffer to fill in.
  45567. * @param scene defines the scene the material belongs to.
  45568. * @param isFrozen defines wether the material is frozen or not.
  45569. */
  45570. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45571. /**
  45572. * Checks to see if a texture is used in the material.
  45573. * @param texture - Base texture to use.
  45574. * @returns - Boolean specifying if a texture is used in the material.
  45575. */
  45576. hasTexture(texture: BaseTexture): boolean;
  45577. /**
  45578. * Returns an array of the actively used textures.
  45579. * @param activeTextures Array of BaseTextures
  45580. */
  45581. getActiveTextures(activeTextures: BaseTexture[]): void;
  45582. /**
  45583. * Returns the animatable textures.
  45584. * @param animatables Array of animatable textures.
  45585. */
  45586. getAnimatables(animatables: IAnimatable[]): void;
  45587. /**
  45588. * Disposes the resources of the material.
  45589. * @param forceDisposeTextures - Forces the disposal of all textures.
  45590. */
  45591. dispose(forceDisposeTextures?: boolean): void;
  45592. /**
  45593. * Get the current class name of the texture useful for serialization or dynamic coding.
  45594. * @returns "PBRSheenConfiguration"
  45595. */
  45596. getClassName(): string;
  45597. /**
  45598. * Add fallbacks to the effect fallbacks list.
  45599. * @param defines defines the Base texture to use.
  45600. * @param fallbacks defines the current fallback list.
  45601. * @param currentRank defines the current fallback rank.
  45602. * @returns the new fallback rank.
  45603. */
  45604. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45605. /**
  45606. * Add the required uniforms to the current list.
  45607. * @param uniforms defines the current uniform list.
  45608. */
  45609. static AddUniforms(uniforms: string[]): void;
  45610. /**
  45611. * Add the required uniforms to the current buffer.
  45612. * @param uniformBuffer defines the current uniform buffer.
  45613. */
  45614. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45615. /**
  45616. * Add the required samplers to the current list.
  45617. * @param samplers defines the current sampler list.
  45618. */
  45619. static AddSamplers(samplers: string[]): void;
  45620. /**
  45621. * Makes a duplicate of the current configuration into another one.
  45622. * @param sheenConfiguration define the config where to copy the info
  45623. */
  45624. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45625. /**
  45626. * Serializes this BRDF configuration.
  45627. * @returns - An object with the serialized config.
  45628. */
  45629. serialize(): any;
  45630. /**
  45631. * Parses a anisotropy Configuration from a serialized object.
  45632. * @param source - Serialized object.
  45633. * @param scene Defines the scene we are parsing for
  45634. * @param rootUrl Defines the rootUrl to load from
  45635. */
  45636. parse(source: any, scene: Scene, rootUrl: string): void;
  45637. }
  45638. }
  45639. declare module BABYLON {
  45640. /**
  45641. * @hidden
  45642. */
  45643. export interface IMaterialSubSurfaceDefines {
  45644. SUBSURFACE: boolean;
  45645. SS_REFRACTION: boolean;
  45646. SS_TRANSLUCENCY: boolean;
  45647. SS_SCATERRING: boolean;
  45648. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45649. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45650. SS_REFRACTIONMAP_3D: boolean;
  45651. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45652. SS_LODINREFRACTIONALPHA: boolean;
  45653. SS_GAMMAREFRACTION: boolean;
  45654. SS_RGBDREFRACTION: boolean;
  45655. SS_LINEARSPECULARREFRACTION: boolean;
  45656. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45657. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45658. /** @hidden */
  45659. _areTexturesDirty: boolean;
  45660. }
  45661. /**
  45662. * Define the code related to the sub surface parameters of the pbr material.
  45663. */
  45664. export class PBRSubSurfaceConfiguration {
  45665. private _isRefractionEnabled;
  45666. /**
  45667. * Defines if the refraction is enabled in the material.
  45668. */
  45669. isRefractionEnabled: boolean;
  45670. private _isTranslucencyEnabled;
  45671. /**
  45672. * Defines if the translucency is enabled in the material.
  45673. */
  45674. isTranslucencyEnabled: boolean;
  45675. private _isScatteringEnabled;
  45676. /**
  45677. * Defines the refraction intensity of the material.
  45678. * The refraction when enabled replaces the Diffuse part of the material.
  45679. * The intensity helps transitionning between diffuse and refraction.
  45680. */
  45681. refractionIntensity: number;
  45682. /**
  45683. * Defines the translucency intensity of the material.
  45684. * When translucency has been enabled, this defines how much of the "translucency"
  45685. * is addded to the diffuse part of the material.
  45686. */
  45687. translucencyIntensity: number;
  45688. /**
  45689. * Defines the scattering intensity of the material.
  45690. * When scattering has been enabled, this defines how much of the "scattered light"
  45691. * is addded to the diffuse part of the material.
  45692. */
  45693. scatteringIntensity: number;
  45694. private _thicknessTexture;
  45695. /**
  45696. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45697. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45698. * 0 would mean minimumThickness
  45699. * 1 would mean maximumThickness
  45700. * The other channels might be use as a mask to vary the different effects intensity.
  45701. */
  45702. thicknessTexture: Nullable<BaseTexture>;
  45703. private _refractionTexture;
  45704. /**
  45705. * Defines the texture to use for refraction.
  45706. */
  45707. refractionTexture: Nullable<BaseTexture>;
  45708. private _indexOfRefraction;
  45709. /**
  45710. * Defines the index of refraction used in the material.
  45711. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45712. */
  45713. indexOfRefraction: number;
  45714. private _invertRefractionY;
  45715. /**
  45716. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45717. */
  45718. invertRefractionY: boolean;
  45719. private _linkRefractionWithTransparency;
  45720. /**
  45721. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45722. * Materials half opaque for instance using refraction could benefit from this control.
  45723. */
  45724. linkRefractionWithTransparency: boolean;
  45725. /**
  45726. * Defines the minimum thickness stored in the thickness map.
  45727. * If no thickness map is defined, this value will be used to simulate thickness.
  45728. */
  45729. minimumThickness: number;
  45730. /**
  45731. * Defines the maximum thickness stored in the thickness map.
  45732. */
  45733. maximumThickness: number;
  45734. /**
  45735. * Defines the volume tint of the material.
  45736. * This is used for both translucency and scattering.
  45737. */
  45738. tintColor: Color3;
  45739. /**
  45740. * Defines the distance at which the tint color should be found in the media.
  45741. * This is used for refraction only.
  45742. */
  45743. tintColorAtDistance: number;
  45744. /**
  45745. * Defines how far each channel transmit through the media.
  45746. * It is defined as a color to simplify it selection.
  45747. */
  45748. diffusionDistance: Color3;
  45749. private _useMaskFromThicknessTexture;
  45750. /**
  45751. * Stores the intensity of the different subsurface effects in the thickness texture.
  45752. * * the green channel is the translucency intensity.
  45753. * * the blue channel is the scattering intensity.
  45754. * * the alpha channel is the refraction intensity.
  45755. */
  45756. useMaskFromThicknessTexture: boolean;
  45757. /** @hidden */
  45758. private _internalMarkAllSubMeshesAsTexturesDirty;
  45759. /** @hidden */
  45760. _markAllSubMeshesAsTexturesDirty(): void;
  45761. /**
  45762. * Instantiate a new istance of sub surface configuration.
  45763. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45764. */
  45765. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45766. /**
  45767. * Gets wehter the submesh is ready to be used or not.
  45768. * @param defines the list of "defines" to update.
  45769. * @param scene defines the scene the material belongs to.
  45770. * @returns - boolean indicating that the submesh is ready or not.
  45771. */
  45772. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45773. /**
  45774. * Checks to see if a texture is used in the material.
  45775. * @param defines the list of "defines" to update.
  45776. * @param scene defines the scene to the material belongs to.
  45777. */
  45778. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45779. /**
  45780. * Binds the material data.
  45781. * @param uniformBuffer defines the Uniform buffer to fill in.
  45782. * @param scene defines the scene the material belongs to.
  45783. * @param engine defines the engine the material belongs to.
  45784. * @param isFrozen defines wether the material is frozen or not.
  45785. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45786. */
  45787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45788. /**
  45789. * Unbinds the material from the mesh.
  45790. * @param activeEffect defines the effect that should be unbound from.
  45791. * @returns true if unbound, otherwise false
  45792. */
  45793. unbind(activeEffect: Effect): boolean;
  45794. /**
  45795. * Returns the texture used for refraction or null if none is used.
  45796. * @param scene defines the scene the material belongs to.
  45797. * @returns - Refraction texture if present. If no refraction texture and refraction
  45798. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45799. */
  45800. private _getRefractionTexture;
  45801. /**
  45802. * Returns true if alpha blending should be disabled.
  45803. */
  45804. readonly disableAlphaBlending: boolean;
  45805. /**
  45806. * Fills the list of render target textures.
  45807. * @param renderTargets the list of render targets to update
  45808. */
  45809. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45810. /**
  45811. * Checks to see if a texture is used in the material.
  45812. * @param texture - Base texture to use.
  45813. * @returns - Boolean specifying if a texture is used in the material.
  45814. */
  45815. hasTexture(texture: BaseTexture): boolean;
  45816. /**
  45817. * Gets a boolean indicating that current material needs to register RTT
  45818. * @returns true if this uses a render target otherwise false.
  45819. */
  45820. hasRenderTargetTextures(): boolean;
  45821. /**
  45822. * Returns an array of the actively used textures.
  45823. * @param activeTextures Array of BaseTextures
  45824. */
  45825. getActiveTextures(activeTextures: BaseTexture[]): void;
  45826. /**
  45827. * Returns the animatable textures.
  45828. * @param animatables Array of animatable textures.
  45829. */
  45830. getAnimatables(animatables: IAnimatable[]): void;
  45831. /**
  45832. * Disposes the resources of the material.
  45833. * @param forceDisposeTextures - Forces the disposal of all textures.
  45834. */
  45835. dispose(forceDisposeTextures?: boolean): void;
  45836. /**
  45837. * Get the current class name of the texture useful for serialization or dynamic coding.
  45838. * @returns "PBRSubSurfaceConfiguration"
  45839. */
  45840. getClassName(): string;
  45841. /**
  45842. * Add fallbacks to the effect fallbacks list.
  45843. * @param defines defines the Base texture to use.
  45844. * @param fallbacks defines the current fallback list.
  45845. * @param currentRank defines the current fallback rank.
  45846. * @returns the new fallback rank.
  45847. */
  45848. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45849. /**
  45850. * Add the required uniforms to the current list.
  45851. * @param uniforms defines the current uniform list.
  45852. */
  45853. static AddUniforms(uniforms: string[]): void;
  45854. /**
  45855. * Add the required samplers to the current list.
  45856. * @param samplers defines the current sampler list.
  45857. */
  45858. static AddSamplers(samplers: string[]): void;
  45859. /**
  45860. * Add the required uniforms to the current buffer.
  45861. * @param uniformBuffer defines the current uniform buffer.
  45862. */
  45863. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45864. /**
  45865. * Makes a duplicate of the current configuration into another one.
  45866. * @param configuration define the config where to copy the info
  45867. */
  45868. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45869. /**
  45870. * Serializes this Sub Surface configuration.
  45871. * @returns - An object with the serialized config.
  45872. */
  45873. serialize(): any;
  45874. /**
  45875. * Parses a anisotropy Configuration from a serialized object.
  45876. * @param source - Serialized object.
  45877. * @param scene Defines the scene we are parsing for
  45878. * @param rootUrl Defines the rootUrl to load from
  45879. */
  45880. parse(source: any, scene: Scene, rootUrl: string): void;
  45881. }
  45882. }
  45883. declare module BABYLON {
  45884. /** @hidden */
  45885. export var pbrFragmentDeclaration: {
  45886. name: string;
  45887. shader: string;
  45888. };
  45889. }
  45890. declare module BABYLON {
  45891. /** @hidden */
  45892. export var pbrUboDeclaration: {
  45893. name: string;
  45894. shader: string;
  45895. };
  45896. }
  45897. declare module BABYLON {
  45898. /** @hidden */
  45899. export var pbrFragmentExtraDeclaration: {
  45900. name: string;
  45901. shader: string;
  45902. };
  45903. }
  45904. declare module BABYLON {
  45905. /** @hidden */
  45906. export var pbrFragmentSamplersDeclaration: {
  45907. name: string;
  45908. shader: string;
  45909. };
  45910. }
  45911. declare module BABYLON {
  45912. /** @hidden */
  45913. export var pbrHelperFunctions: {
  45914. name: string;
  45915. shader: string;
  45916. };
  45917. }
  45918. declare module BABYLON {
  45919. /** @hidden */
  45920. export var harmonicsFunctions: {
  45921. name: string;
  45922. shader: string;
  45923. };
  45924. }
  45925. declare module BABYLON {
  45926. /** @hidden */
  45927. export var pbrDirectLightingSetupFunctions: {
  45928. name: string;
  45929. shader: string;
  45930. };
  45931. }
  45932. declare module BABYLON {
  45933. /** @hidden */
  45934. export var pbrDirectLightingFalloffFunctions: {
  45935. name: string;
  45936. shader: string;
  45937. };
  45938. }
  45939. declare module BABYLON {
  45940. /** @hidden */
  45941. export var pbrBRDFFunctions: {
  45942. name: string;
  45943. shader: string;
  45944. };
  45945. }
  45946. declare module BABYLON {
  45947. /** @hidden */
  45948. export var pbrDirectLightingFunctions: {
  45949. name: string;
  45950. shader: string;
  45951. };
  45952. }
  45953. declare module BABYLON {
  45954. /** @hidden */
  45955. export var pbrIBLFunctions: {
  45956. name: string;
  45957. shader: string;
  45958. };
  45959. }
  45960. declare module BABYLON {
  45961. /** @hidden */
  45962. export var pbrDebug: {
  45963. name: string;
  45964. shader: string;
  45965. };
  45966. }
  45967. declare module BABYLON {
  45968. /** @hidden */
  45969. export var pbrPixelShader: {
  45970. name: string;
  45971. shader: string;
  45972. };
  45973. }
  45974. declare module BABYLON {
  45975. /** @hidden */
  45976. export var pbrVertexDeclaration: {
  45977. name: string;
  45978. shader: string;
  45979. };
  45980. }
  45981. declare module BABYLON {
  45982. /** @hidden */
  45983. export var pbrVertexShader: {
  45984. name: string;
  45985. shader: string;
  45986. };
  45987. }
  45988. declare module BABYLON {
  45989. /**
  45990. * Manages the defines for the PBR Material.
  45991. * @hidden
  45992. */
  45993. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45994. PBR: boolean;
  45995. MAINUV1: boolean;
  45996. MAINUV2: boolean;
  45997. UV1: boolean;
  45998. UV2: boolean;
  45999. ALBEDO: boolean;
  46000. ALBEDODIRECTUV: number;
  46001. VERTEXCOLOR: boolean;
  46002. AMBIENT: boolean;
  46003. AMBIENTDIRECTUV: number;
  46004. AMBIENTINGRAYSCALE: boolean;
  46005. OPACITY: boolean;
  46006. VERTEXALPHA: boolean;
  46007. OPACITYDIRECTUV: number;
  46008. OPACITYRGB: boolean;
  46009. ALPHATEST: boolean;
  46010. DEPTHPREPASS: boolean;
  46011. ALPHABLEND: boolean;
  46012. ALPHAFROMALBEDO: boolean;
  46013. ALPHATESTVALUE: string;
  46014. SPECULAROVERALPHA: boolean;
  46015. RADIANCEOVERALPHA: boolean;
  46016. ALPHAFRESNEL: boolean;
  46017. LINEARALPHAFRESNEL: boolean;
  46018. PREMULTIPLYALPHA: boolean;
  46019. EMISSIVE: boolean;
  46020. EMISSIVEDIRECTUV: number;
  46021. REFLECTIVITY: boolean;
  46022. REFLECTIVITYDIRECTUV: number;
  46023. SPECULARTERM: boolean;
  46024. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46025. MICROSURFACEAUTOMATIC: boolean;
  46026. LODBASEDMICROSFURACE: boolean;
  46027. MICROSURFACEMAP: boolean;
  46028. MICROSURFACEMAPDIRECTUV: number;
  46029. METALLICWORKFLOW: boolean;
  46030. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46031. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46032. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46033. AOSTOREINMETALMAPRED: boolean;
  46034. ENVIRONMENTBRDF: boolean;
  46035. ENVIRONMENTBRDF_RGBD: boolean;
  46036. NORMAL: boolean;
  46037. TANGENT: boolean;
  46038. BUMP: boolean;
  46039. BUMPDIRECTUV: number;
  46040. OBJECTSPACE_NORMALMAP: boolean;
  46041. PARALLAX: boolean;
  46042. PARALLAXOCCLUSION: boolean;
  46043. NORMALXYSCALE: boolean;
  46044. LIGHTMAP: boolean;
  46045. LIGHTMAPDIRECTUV: number;
  46046. USELIGHTMAPASSHADOWMAP: boolean;
  46047. GAMMALIGHTMAP: boolean;
  46048. REFLECTION: boolean;
  46049. REFLECTIONMAP_3D: boolean;
  46050. REFLECTIONMAP_SPHERICAL: boolean;
  46051. REFLECTIONMAP_PLANAR: boolean;
  46052. REFLECTIONMAP_CUBIC: boolean;
  46053. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46054. REFLECTIONMAP_PROJECTION: boolean;
  46055. REFLECTIONMAP_SKYBOX: boolean;
  46056. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46057. REFLECTIONMAP_EXPLICIT: boolean;
  46058. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46059. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46060. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46061. INVERTCUBICMAP: boolean;
  46062. USESPHERICALFROMREFLECTIONMAP: boolean;
  46063. USEIRRADIANCEMAP: boolean;
  46064. SPHERICAL_HARMONICS: boolean;
  46065. USESPHERICALINVERTEX: boolean;
  46066. REFLECTIONMAP_OPPOSITEZ: boolean;
  46067. LODINREFLECTIONALPHA: boolean;
  46068. GAMMAREFLECTION: boolean;
  46069. RGBDREFLECTION: boolean;
  46070. LINEARSPECULARREFLECTION: boolean;
  46071. RADIANCEOCCLUSION: boolean;
  46072. HORIZONOCCLUSION: boolean;
  46073. INSTANCES: boolean;
  46074. NUM_BONE_INFLUENCERS: number;
  46075. BonesPerMesh: number;
  46076. BONETEXTURE: boolean;
  46077. NONUNIFORMSCALING: boolean;
  46078. MORPHTARGETS: boolean;
  46079. MORPHTARGETS_NORMAL: boolean;
  46080. MORPHTARGETS_TANGENT: boolean;
  46081. MORPHTARGETS_UV: boolean;
  46082. NUM_MORPH_INFLUENCERS: number;
  46083. IMAGEPROCESSING: boolean;
  46084. VIGNETTE: boolean;
  46085. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46086. VIGNETTEBLENDMODEOPAQUE: boolean;
  46087. TONEMAPPING: boolean;
  46088. TONEMAPPING_ACES: boolean;
  46089. CONTRAST: boolean;
  46090. COLORCURVES: boolean;
  46091. COLORGRADING: boolean;
  46092. COLORGRADING3D: boolean;
  46093. SAMPLER3DGREENDEPTH: boolean;
  46094. SAMPLER3DBGRMAP: boolean;
  46095. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46096. EXPOSURE: boolean;
  46097. MULTIVIEW: boolean;
  46098. USEPHYSICALLIGHTFALLOFF: boolean;
  46099. USEGLTFLIGHTFALLOFF: boolean;
  46100. TWOSIDEDLIGHTING: boolean;
  46101. SHADOWFLOAT: boolean;
  46102. CLIPPLANE: boolean;
  46103. CLIPPLANE2: boolean;
  46104. CLIPPLANE3: boolean;
  46105. CLIPPLANE4: boolean;
  46106. POINTSIZE: boolean;
  46107. FOG: boolean;
  46108. LOGARITHMICDEPTH: boolean;
  46109. FORCENORMALFORWARD: boolean;
  46110. SPECULARAA: boolean;
  46111. CLEARCOAT: boolean;
  46112. CLEARCOAT_DEFAULTIOR: boolean;
  46113. CLEARCOAT_TEXTURE: boolean;
  46114. CLEARCOAT_TEXTUREDIRECTUV: number;
  46115. CLEARCOAT_BUMP: boolean;
  46116. CLEARCOAT_BUMPDIRECTUV: number;
  46117. CLEARCOAT_TINT: boolean;
  46118. CLEARCOAT_TINT_TEXTURE: boolean;
  46119. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46120. ANISOTROPIC: boolean;
  46121. ANISOTROPIC_TEXTURE: boolean;
  46122. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46123. BRDF_V_HEIGHT_CORRELATED: boolean;
  46124. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46125. SHEEN: boolean;
  46126. SHEEN_TEXTURE: boolean;
  46127. SHEEN_TEXTUREDIRECTUV: number;
  46128. SHEEN_LINKWITHALBEDO: boolean;
  46129. SUBSURFACE: boolean;
  46130. SS_REFRACTION: boolean;
  46131. SS_TRANSLUCENCY: boolean;
  46132. SS_SCATERRING: boolean;
  46133. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46134. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46135. SS_REFRACTIONMAP_3D: boolean;
  46136. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46137. SS_LODINREFRACTIONALPHA: boolean;
  46138. SS_GAMMAREFRACTION: boolean;
  46139. SS_RGBDREFRACTION: boolean;
  46140. SS_LINEARSPECULARREFRACTION: boolean;
  46141. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46142. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46143. UNLIT: boolean;
  46144. DEBUGMODE: number;
  46145. /**
  46146. * Initializes the PBR Material defines.
  46147. */
  46148. constructor();
  46149. /**
  46150. * Resets the PBR Material defines.
  46151. */
  46152. reset(): void;
  46153. }
  46154. /**
  46155. * The Physically based material base class of BJS.
  46156. *
  46157. * This offers the main features of a standard PBR material.
  46158. * For more information, please refer to the documentation :
  46159. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46160. */
  46161. export abstract class PBRBaseMaterial extends PushMaterial {
  46162. /**
  46163. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46164. */
  46165. static readonly PBRMATERIAL_OPAQUE: number;
  46166. /**
  46167. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46168. */
  46169. static readonly PBRMATERIAL_ALPHATEST: number;
  46170. /**
  46171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46172. */
  46173. static readonly PBRMATERIAL_ALPHABLEND: number;
  46174. /**
  46175. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46176. * They are also discarded below the alpha cutoff threshold to improve performances.
  46177. */
  46178. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46179. /**
  46180. * Defines the default value of how much AO map is occluding the analytical lights
  46181. * (point spot...).
  46182. */
  46183. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46184. /**
  46185. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46186. */
  46187. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46188. /**
  46189. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46190. * to enhance interoperability with other engines.
  46191. */
  46192. static readonly LIGHTFALLOFF_GLTF: number;
  46193. /**
  46194. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46195. * to enhance interoperability with other materials.
  46196. */
  46197. static readonly LIGHTFALLOFF_STANDARD: number;
  46198. /**
  46199. * Intensity of the direct lights e.g. the four lights available in your scene.
  46200. * This impacts both the direct diffuse and specular highlights.
  46201. */
  46202. protected _directIntensity: number;
  46203. /**
  46204. * Intensity of the emissive part of the material.
  46205. * This helps controlling the emissive effect without modifying the emissive color.
  46206. */
  46207. protected _emissiveIntensity: number;
  46208. /**
  46209. * Intensity of the environment e.g. how much the environment will light the object
  46210. * either through harmonics for rough material or through the refelction for shiny ones.
  46211. */
  46212. protected _environmentIntensity: number;
  46213. /**
  46214. * This is a special control allowing the reduction of the specular highlights coming from the
  46215. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46216. */
  46217. protected _specularIntensity: number;
  46218. /**
  46219. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46220. */
  46221. private _lightingInfos;
  46222. /**
  46223. * Debug Control allowing disabling the bump map on this material.
  46224. */
  46225. protected _disableBumpMap: boolean;
  46226. /**
  46227. * AKA Diffuse Texture in standard nomenclature.
  46228. */
  46229. protected _albedoTexture: Nullable<BaseTexture>;
  46230. /**
  46231. * AKA Occlusion Texture in other nomenclature.
  46232. */
  46233. protected _ambientTexture: Nullable<BaseTexture>;
  46234. /**
  46235. * AKA Occlusion Texture Intensity in other nomenclature.
  46236. */
  46237. protected _ambientTextureStrength: number;
  46238. /**
  46239. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46240. * 1 means it completely occludes it
  46241. * 0 mean it has no impact
  46242. */
  46243. protected _ambientTextureImpactOnAnalyticalLights: number;
  46244. /**
  46245. * Stores the alpha values in a texture.
  46246. */
  46247. protected _opacityTexture: Nullable<BaseTexture>;
  46248. /**
  46249. * Stores the reflection values in a texture.
  46250. */
  46251. protected _reflectionTexture: Nullable<BaseTexture>;
  46252. /**
  46253. * Stores the emissive values in a texture.
  46254. */
  46255. protected _emissiveTexture: Nullable<BaseTexture>;
  46256. /**
  46257. * AKA Specular texture in other nomenclature.
  46258. */
  46259. protected _reflectivityTexture: Nullable<BaseTexture>;
  46260. /**
  46261. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46262. */
  46263. protected _metallicTexture: Nullable<BaseTexture>;
  46264. /**
  46265. * Specifies the metallic scalar of the metallic/roughness workflow.
  46266. * Can also be used to scale the metalness values of the metallic texture.
  46267. */
  46268. protected _metallic: Nullable<number>;
  46269. /**
  46270. * Specifies the roughness scalar of the metallic/roughness workflow.
  46271. * Can also be used to scale the roughness values of the metallic texture.
  46272. */
  46273. protected _roughness: Nullable<number>;
  46274. /**
  46275. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46276. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46277. */
  46278. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46279. /**
  46280. * Stores surface normal data used to displace a mesh in a texture.
  46281. */
  46282. protected _bumpTexture: Nullable<BaseTexture>;
  46283. /**
  46284. * Stores the pre-calculated light information of a mesh in a texture.
  46285. */
  46286. protected _lightmapTexture: Nullable<BaseTexture>;
  46287. /**
  46288. * The color of a material in ambient lighting.
  46289. */
  46290. protected _ambientColor: Color3;
  46291. /**
  46292. * AKA Diffuse Color in other nomenclature.
  46293. */
  46294. protected _albedoColor: Color3;
  46295. /**
  46296. * AKA Specular Color in other nomenclature.
  46297. */
  46298. protected _reflectivityColor: Color3;
  46299. /**
  46300. * The color applied when light is reflected from a material.
  46301. */
  46302. protected _reflectionColor: Color3;
  46303. /**
  46304. * The color applied when light is emitted from a material.
  46305. */
  46306. protected _emissiveColor: Color3;
  46307. /**
  46308. * AKA Glossiness in other nomenclature.
  46309. */
  46310. protected _microSurface: number;
  46311. /**
  46312. * Specifies that the material will use the light map as a show map.
  46313. */
  46314. protected _useLightmapAsShadowmap: boolean;
  46315. /**
  46316. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46317. * makes the reflect vector face the model (under horizon).
  46318. */
  46319. protected _useHorizonOcclusion: boolean;
  46320. /**
  46321. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46322. * too much the area relying on ambient texture to define their ambient occlusion.
  46323. */
  46324. protected _useRadianceOcclusion: boolean;
  46325. /**
  46326. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46327. */
  46328. protected _useAlphaFromAlbedoTexture: boolean;
  46329. /**
  46330. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46332. */
  46333. protected _useSpecularOverAlpha: boolean;
  46334. /**
  46335. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46336. */
  46337. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46338. /**
  46339. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46340. */
  46341. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46342. /**
  46343. * Specifies if the metallic texture contains the roughness information in its green channel.
  46344. */
  46345. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46346. /**
  46347. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46348. */
  46349. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46350. /**
  46351. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46352. */
  46353. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46354. /**
  46355. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46356. */
  46357. protected _useAmbientInGrayScale: boolean;
  46358. /**
  46359. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46360. * The material will try to infer what glossiness each pixel should be.
  46361. */
  46362. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46363. /**
  46364. * Defines the falloff type used in this material.
  46365. * It by default is Physical.
  46366. */
  46367. protected _lightFalloff: number;
  46368. /**
  46369. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46370. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46371. */
  46372. protected _useRadianceOverAlpha: boolean;
  46373. /**
  46374. * Allows using an object space normal map (instead of tangent space).
  46375. */
  46376. protected _useObjectSpaceNormalMap: boolean;
  46377. /**
  46378. * Allows using the bump map in parallax mode.
  46379. */
  46380. protected _useParallax: boolean;
  46381. /**
  46382. * Allows using the bump map in parallax occlusion mode.
  46383. */
  46384. protected _useParallaxOcclusion: boolean;
  46385. /**
  46386. * Controls the scale bias of the parallax mode.
  46387. */
  46388. protected _parallaxScaleBias: number;
  46389. /**
  46390. * If sets to true, disables all the lights affecting the material.
  46391. */
  46392. protected _disableLighting: boolean;
  46393. /**
  46394. * Number of Simultaneous lights allowed on the material.
  46395. */
  46396. protected _maxSimultaneousLights: number;
  46397. /**
  46398. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46399. */
  46400. protected _invertNormalMapX: boolean;
  46401. /**
  46402. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46403. */
  46404. protected _invertNormalMapY: boolean;
  46405. /**
  46406. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46407. */
  46408. protected _twoSidedLighting: boolean;
  46409. /**
  46410. * Defines the alpha limits in alpha test mode.
  46411. */
  46412. protected _alphaCutOff: number;
  46413. /**
  46414. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46415. */
  46416. protected _forceAlphaTest: boolean;
  46417. /**
  46418. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46419. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46420. */
  46421. protected _useAlphaFresnel: boolean;
  46422. /**
  46423. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46424. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46425. */
  46426. protected _useLinearAlphaFresnel: boolean;
  46427. /**
  46428. * The transparency mode of the material.
  46429. */
  46430. protected _transparencyMode: Nullable<number>;
  46431. /**
  46432. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46433. * from cos thetav and roughness:
  46434. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46435. */
  46436. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46437. /**
  46438. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46439. */
  46440. protected _forceIrradianceInFragment: boolean;
  46441. /**
  46442. * Force normal to face away from face.
  46443. */
  46444. protected _forceNormalForward: boolean;
  46445. /**
  46446. * Enables specular anti aliasing in the PBR shader.
  46447. * It will both interacts on the Geometry for analytical and IBL lighting.
  46448. * It also prefilter the roughness map based on the bump values.
  46449. */
  46450. protected _enableSpecularAntiAliasing: boolean;
  46451. /**
  46452. * Default configuration related to image processing available in the PBR Material.
  46453. */
  46454. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46455. /**
  46456. * Keep track of the image processing observer to allow dispose and replace.
  46457. */
  46458. private _imageProcessingObserver;
  46459. /**
  46460. * Attaches a new image processing configuration to the PBR Material.
  46461. * @param configuration
  46462. */
  46463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46464. /**
  46465. * Stores the available render targets.
  46466. */
  46467. private _renderTargets;
  46468. /**
  46469. * Sets the global ambient color for the material used in lighting calculations.
  46470. */
  46471. private _globalAmbientColor;
  46472. /**
  46473. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46474. */
  46475. private _useLogarithmicDepth;
  46476. /**
  46477. * If set to true, no lighting calculations will be applied.
  46478. */
  46479. private _unlit;
  46480. private _debugMode;
  46481. /**
  46482. * @hidden
  46483. * This is reserved for the inspector.
  46484. * Defines the material debug mode.
  46485. * It helps seeing only some components of the material while troubleshooting.
  46486. */
  46487. debugMode: number;
  46488. /**
  46489. * @hidden
  46490. * This is reserved for the inspector.
  46491. * Specify from where on screen the debug mode should start.
  46492. * The value goes from -1 (full screen) to 1 (not visible)
  46493. * It helps with side by side comparison against the final render
  46494. * This defaults to -1
  46495. */
  46496. private debugLimit;
  46497. /**
  46498. * @hidden
  46499. * This is reserved for the inspector.
  46500. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46501. * You can use the factor to better multiply the final value.
  46502. */
  46503. private debugFactor;
  46504. /**
  46505. * Defines the clear coat layer parameters for the material.
  46506. */
  46507. readonly clearCoat: PBRClearCoatConfiguration;
  46508. /**
  46509. * Defines the anisotropic parameters for the material.
  46510. */
  46511. readonly anisotropy: PBRAnisotropicConfiguration;
  46512. /**
  46513. * Defines the BRDF parameters for the material.
  46514. */
  46515. readonly brdf: PBRBRDFConfiguration;
  46516. /**
  46517. * Defines the Sheen parameters for the material.
  46518. */
  46519. readonly sheen: PBRSheenConfiguration;
  46520. /**
  46521. * Defines the SubSurface parameters for the material.
  46522. */
  46523. readonly subSurface: PBRSubSurfaceConfiguration;
  46524. /**
  46525. * Custom callback helping to override the default shader used in the material.
  46526. */
  46527. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46528. /**
  46529. * Instantiates a new PBRMaterial instance.
  46530. *
  46531. * @param name The material name
  46532. * @param scene The scene the material will be use in.
  46533. */
  46534. constructor(name: string, scene: Scene);
  46535. /**
  46536. * Gets a boolean indicating that current material needs to register RTT
  46537. */
  46538. readonly hasRenderTargetTextures: boolean;
  46539. /**
  46540. * Gets the name of the material class.
  46541. */
  46542. getClassName(): string;
  46543. /**
  46544. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46545. */
  46546. /**
  46547. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46548. */
  46549. useLogarithmicDepth: boolean;
  46550. /**
  46551. * Gets the current transparency mode.
  46552. */
  46553. /**
  46554. * Sets the transparency mode of the material.
  46555. *
  46556. * | Value | Type | Description |
  46557. * | ----- | ----------------------------------- | ----------- |
  46558. * | 0 | OPAQUE | |
  46559. * | 1 | ALPHATEST | |
  46560. * | 2 | ALPHABLEND | |
  46561. * | 3 | ALPHATESTANDBLEND | |
  46562. *
  46563. */
  46564. transparencyMode: Nullable<number>;
  46565. /**
  46566. * Returns true if alpha blending should be disabled.
  46567. */
  46568. private readonly _disableAlphaBlending;
  46569. /**
  46570. * Specifies whether or not this material should be rendered in alpha blend mode.
  46571. */
  46572. needAlphaBlending(): boolean;
  46573. /**
  46574. * Specifies if the mesh will require alpha blending.
  46575. * @param mesh - BJS mesh.
  46576. */
  46577. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46578. /**
  46579. * Specifies whether or not this material should be rendered in alpha test mode.
  46580. */
  46581. needAlphaTesting(): boolean;
  46582. /**
  46583. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46584. */
  46585. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46586. /**
  46587. * Gets the texture used for the alpha test.
  46588. */
  46589. getAlphaTestTexture(): Nullable<BaseTexture>;
  46590. /**
  46591. * Specifies that the submesh is ready to be used.
  46592. * @param mesh - BJS mesh.
  46593. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46594. * @param useInstances - Specifies that instances should be used.
  46595. * @returns - boolean indicating that the submesh is ready or not.
  46596. */
  46597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46598. /**
  46599. * Specifies if the material uses metallic roughness workflow.
  46600. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46601. */
  46602. isMetallicWorkflow(): boolean;
  46603. private _prepareEffect;
  46604. private _prepareDefines;
  46605. /**
  46606. * Force shader compilation
  46607. */
  46608. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46609. clipPlane: boolean;
  46610. }>): void;
  46611. /**
  46612. * Initializes the uniform buffer layout for the shader.
  46613. */
  46614. buildUniformLayout(): void;
  46615. /**
  46616. * Unbinds the material from the mesh
  46617. */
  46618. unbind(): void;
  46619. /**
  46620. * Binds the submesh data.
  46621. * @param world - The world matrix.
  46622. * @param mesh - The BJS mesh.
  46623. * @param subMesh - A submesh of the BJS mesh.
  46624. */
  46625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46626. /**
  46627. * Returns the animatable textures.
  46628. * @returns - Array of animatable textures.
  46629. */
  46630. getAnimatables(): IAnimatable[];
  46631. /**
  46632. * Returns the texture used for reflections.
  46633. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46634. */
  46635. private _getReflectionTexture;
  46636. /**
  46637. * Returns an array of the actively used textures.
  46638. * @returns - Array of BaseTextures
  46639. */
  46640. getActiveTextures(): BaseTexture[];
  46641. /**
  46642. * Checks to see if a texture is used in the material.
  46643. * @param texture - Base texture to use.
  46644. * @returns - Boolean specifying if a texture is used in the material.
  46645. */
  46646. hasTexture(texture: BaseTexture): boolean;
  46647. /**
  46648. * Disposes the resources of the material.
  46649. * @param forceDisposeEffect - Forces the disposal of effects.
  46650. * @param forceDisposeTextures - Forces the disposal of all textures.
  46651. */
  46652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46653. }
  46654. }
  46655. declare module BABYLON {
  46656. /**
  46657. * The Physically based material of BJS.
  46658. *
  46659. * This offers the main features of a standard PBR material.
  46660. * For more information, please refer to the documentation :
  46661. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46662. */
  46663. export class PBRMaterial extends PBRBaseMaterial {
  46664. /**
  46665. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46666. */
  46667. static readonly PBRMATERIAL_OPAQUE: number;
  46668. /**
  46669. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46670. */
  46671. static readonly PBRMATERIAL_ALPHATEST: number;
  46672. /**
  46673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46674. */
  46675. static readonly PBRMATERIAL_ALPHABLEND: number;
  46676. /**
  46677. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46678. * They are also discarded below the alpha cutoff threshold to improve performances.
  46679. */
  46680. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46681. /**
  46682. * Defines the default value of how much AO map is occluding the analytical lights
  46683. * (point spot...).
  46684. */
  46685. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46686. /**
  46687. * Intensity of the direct lights e.g. the four lights available in your scene.
  46688. * This impacts both the direct diffuse and specular highlights.
  46689. */
  46690. directIntensity: number;
  46691. /**
  46692. * Intensity of the emissive part of the material.
  46693. * This helps controlling the emissive effect without modifying the emissive color.
  46694. */
  46695. emissiveIntensity: number;
  46696. /**
  46697. * Intensity of the environment e.g. how much the environment will light the object
  46698. * either through harmonics for rough material or through the refelction for shiny ones.
  46699. */
  46700. environmentIntensity: number;
  46701. /**
  46702. * This is a special control allowing the reduction of the specular highlights coming from the
  46703. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46704. */
  46705. specularIntensity: number;
  46706. /**
  46707. * Debug Control allowing disabling the bump map on this material.
  46708. */
  46709. disableBumpMap: boolean;
  46710. /**
  46711. * AKA Diffuse Texture in standard nomenclature.
  46712. */
  46713. albedoTexture: BaseTexture;
  46714. /**
  46715. * AKA Occlusion Texture in other nomenclature.
  46716. */
  46717. ambientTexture: BaseTexture;
  46718. /**
  46719. * AKA Occlusion Texture Intensity in other nomenclature.
  46720. */
  46721. ambientTextureStrength: number;
  46722. /**
  46723. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46724. * 1 means it completely occludes it
  46725. * 0 mean it has no impact
  46726. */
  46727. ambientTextureImpactOnAnalyticalLights: number;
  46728. /**
  46729. * Stores the alpha values in a texture.
  46730. */
  46731. opacityTexture: BaseTexture;
  46732. /**
  46733. * Stores the reflection values in a texture.
  46734. */
  46735. reflectionTexture: Nullable<BaseTexture>;
  46736. /**
  46737. * Stores the emissive values in a texture.
  46738. */
  46739. emissiveTexture: BaseTexture;
  46740. /**
  46741. * AKA Specular texture in other nomenclature.
  46742. */
  46743. reflectivityTexture: BaseTexture;
  46744. /**
  46745. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46746. */
  46747. metallicTexture: BaseTexture;
  46748. /**
  46749. * Specifies the metallic scalar of the metallic/roughness workflow.
  46750. * Can also be used to scale the metalness values of the metallic texture.
  46751. */
  46752. metallic: Nullable<number>;
  46753. /**
  46754. * Specifies the roughness scalar of the metallic/roughness workflow.
  46755. * Can also be used to scale the roughness values of the metallic texture.
  46756. */
  46757. roughness: Nullable<number>;
  46758. /**
  46759. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46760. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46761. */
  46762. microSurfaceTexture: BaseTexture;
  46763. /**
  46764. * Stores surface normal data used to displace a mesh in a texture.
  46765. */
  46766. bumpTexture: BaseTexture;
  46767. /**
  46768. * Stores the pre-calculated light information of a mesh in a texture.
  46769. */
  46770. lightmapTexture: BaseTexture;
  46771. /**
  46772. * Stores the refracted light information in a texture.
  46773. */
  46774. refractionTexture: Nullable<BaseTexture>;
  46775. /**
  46776. * The color of a material in ambient lighting.
  46777. */
  46778. ambientColor: Color3;
  46779. /**
  46780. * AKA Diffuse Color in other nomenclature.
  46781. */
  46782. albedoColor: Color3;
  46783. /**
  46784. * AKA Specular Color in other nomenclature.
  46785. */
  46786. reflectivityColor: Color3;
  46787. /**
  46788. * The color reflected from the material.
  46789. */
  46790. reflectionColor: Color3;
  46791. /**
  46792. * The color emitted from the material.
  46793. */
  46794. emissiveColor: Color3;
  46795. /**
  46796. * AKA Glossiness in other nomenclature.
  46797. */
  46798. microSurface: number;
  46799. /**
  46800. * source material index of refraction (IOR)' / 'destination material IOR.
  46801. */
  46802. indexOfRefraction: number;
  46803. /**
  46804. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46805. */
  46806. invertRefractionY: boolean;
  46807. /**
  46808. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46809. * Materials half opaque for instance using refraction could benefit from this control.
  46810. */
  46811. linkRefractionWithTransparency: boolean;
  46812. /**
  46813. * If true, the light map contains occlusion information instead of lighting info.
  46814. */
  46815. useLightmapAsShadowmap: boolean;
  46816. /**
  46817. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46818. */
  46819. useAlphaFromAlbedoTexture: boolean;
  46820. /**
  46821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46822. */
  46823. forceAlphaTest: boolean;
  46824. /**
  46825. * Defines the alpha limits in alpha test mode.
  46826. */
  46827. alphaCutOff: number;
  46828. /**
  46829. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46830. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46831. */
  46832. useSpecularOverAlpha: boolean;
  46833. /**
  46834. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46835. */
  46836. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46837. /**
  46838. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46839. */
  46840. useRoughnessFromMetallicTextureAlpha: boolean;
  46841. /**
  46842. * Specifies if the metallic texture contains the roughness information in its green channel.
  46843. */
  46844. useRoughnessFromMetallicTextureGreen: boolean;
  46845. /**
  46846. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46847. */
  46848. useMetallnessFromMetallicTextureBlue: boolean;
  46849. /**
  46850. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46851. */
  46852. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46853. /**
  46854. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46855. */
  46856. useAmbientInGrayScale: boolean;
  46857. /**
  46858. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46859. * The material will try to infer what glossiness each pixel should be.
  46860. */
  46861. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46862. /**
  46863. * BJS is using an harcoded light falloff based on a manually sets up range.
  46864. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46865. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46866. */
  46867. /**
  46868. * BJS is using an harcoded light falloff based on a manually sets up range.
  46869. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46870. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46871. */
  46872. usePhysicalLightFalloff: boolean;
  46873. /**
  46874. * In order to support the falloff compatibility with gltf, a special mode has been added
  46875. * to reproduce the gltf light falloff.
  46876. */
  46877. /**
  46878. * In order to support the falloff compatibility with gltf, a special mode has been added
  46879. * to reproduce the gltf light falloff.
  46880. */
  46881. useGLTFLightFalloff: boolean;
  46882. /**
  46883. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46884. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46885. */
  46886. useRadianceOverAlpha: boolean;
  46887. /**
  46888. * Allows using an object space normal map (instead of tangent space).
  46889. */
  46890. useObjectSpaceNormalMap: boolean;
  46891. /**
  46892. * Allows using the bump map in parallax mode.
  46893. */
  46894. useParallax: boolean;
  46895. /**
  46896. * Allows using the bump map in parallax occlusion mode.
  46897. */
  46898. useParallaxOcclusion: boolean;
  46899. /**
  46900. * Controls the scale bias of the parallax mode.
  46901. */
  46902. parallaxScaleBias: number;
  46903. /**
  46904. * If sets to true, disables all the lights affecting the material.
  46905. */
  46906. disableLighting: boolean;
  46907. /**
  46908. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46909. */
  46910. forceIrradianceInFragment: boolean;
  46911. /**
  46912. * Number of Simultaneous lights allowed on the material.
  46913. */
  46914. maxSimultaneousLights: number;
  46915. /**
  46916. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46917. */
  46918. invertNormalMapX: boolean;
  46919. /**
  46920. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46921. */
  46922. invertNormalMapY: boolean;
  46923. /**
  46924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46925. */
  46926. twoSidedLighting: boolean;
  46927. /**
  46928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46929. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46930. */
  46931. useAlphaFresnel: boolean;
  46932. /**
  46933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46934. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46935. */
  46936. useLinearAlphaFresnel: boolean;
  46937. /**
  46938. * Let user defines the brdf lookup texture used for IBL.
  46939. * A default 8bit version is embedded but you could point at :
  46940. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46941. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46942. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46943. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46944. */
  46945. environmentBRDFTexture: Nullable<BaseTexture>;
  46946. /**
  46947. * Force normal to face away from face.
  46948. */
  46949. forceNormalForward: boolean;
  46950. /**
  46951. * Enables specular anti aliasing in the PBR shader.
  46952. * It will both interacts on the Geometry for analytical and IBL lighting.
  46953. * It also prefilter the roughness map based on the bump values.
  46954. */
  46955. enableSpecularAntiAliasing: boolean;
  46956. /**
  46957. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46958. * makes the reflect vector face the model (under horizon).
  46959. */
  46960. useHorizonOcclusion: boolean;
  46961. /**
  46962. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46963. * too much the area relying on ambient texture to define their ambient occlusion.
  46964. */
  46965. useRadianceOcclusion: boolean;
  46966. /**
  46967. * If set to true, no lighting calculations will be applied.
  46968. */
  46969. unlit: boolean;
  46970. /**
  46971. * Gets the image processing configuration used either in this material.
  46972. */
  46973. /**
  46974. * Sets the Default image processing configuration used either in the this material.
  46975. *
  46976. * If sets to null, the scene one is in use.
  46977. */
  46978. imageProcessingConfiguration: ImageProcessingConfiguration;
  46979. /**
  46980. * Gets wether the color curves effect is enabled.
  46981. */
  46982. /**
  46983. * Sets wether the color curves effect is enabled.
  46984. */
  46985. cameraColorCurvesEnabled: boolean;
  46986. /**
  46987. * Gets wether the color grading effect is enabled.
  46988. */
  46989. /**
  46990. * Gets wether the color grading effect is enabled.
  46991. */
  46992. cameraColorGradingEnabled: boolean;
  46993. /**
  46994. * Gets wether tonemapping is enabled or not.
  46995. */
  46996. /**
  46997. * Sets wether tonemapping is enabled or not
  46998. */
  46999. cameraToneMappingEnabled: boolean;
  47000. /**
  47001. * The camera exposure used on this material.
  47002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47003. * This corresponds to a photographic exposure.
  47004. */
  47005. /**
  47006. * The camera exposure used on this material.
  47007. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47008. * This corresponds to a photographic exposure.
  47009. */
  47010. cameraExposure: number;
  47011. /**
  47012. * Gets The camera contrast used on this material.
  47013. */
  47014. /**
  47015. * Sets The camera contrast used on this material.
  47016. */
  47017. cameraContrast: number;
  47018. /**
  47019. * Gets the Color Grading 2D Lookup Texture.
  47020. */
  47021. /**
  47022. * Sets the Color Grading 2D Lookup Texture.
  47023. */
  47024. cameraColorGradingTexture: Nullable<BaseTexture>;
  47025. /**
  47026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47028. * 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;
  47029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47030. */
  47031. /**
  47032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47034. * 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;
  47035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47036. */
  47037. cameraColorCurves: Nullable<ColorCurves>;
  47038. /**
  47039. * Instantiates a new PBRMaterial instance.
  47040. *
  47041. * @param name The material name
  47042. * @param scene The scene the material will be use in.
  47043. */
  47044. constructor(name: string, scene: Scene);
  47045. /**
  47046. * Returns the name of this material class.
  47047. */
  47048. getClassName(): string;
  47049. /**
  47050. * Makes a duplicate of the current material.
  47051. * @param name - name to use for the new material.
  47052. */
  47053. clone(name: string): PBRMaterial;
  47054. /**
  47055. * Serializes this PBR Material.
  47056. * @returns - An object with the serialized material.
  47057. */
  47058. serialize(): any;
  47059. /**
  47060. * Parses a PBR Material from a serialized object.
  47061. * @param source - Serialized object.
  47062. * @param scene - BJS scene instance.
  47063. * @param rootUrl - url for the scene object
  47064. * @returns - PBRMaterial
  47065. */
  47066. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * Direct draw surface info
  47072. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47073. */
  47074. export interface DDSInfo {
  47075. /**
  47076. * Width of the texture
  47077. */
  47078. width: number;
  47079. /**
  47080. * Width of the texture
  47081. */
  47082. height: number;
  47083. /**
  47084. * Number of Mipmaps for the texture
  47085. * @see https://en.wikipedia.org/wiki/Mipmap
  47086. */
  47087. mipmapCount: number;
  47088. /**
  47089. * If the textures format is a known fourCC format
  47090. * @see https://www.fourcc.org/
  47091. */
  47092. isFourCC: boolean;
  47093. /**
  47094. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47095. */
  47096. isRGB: boolean;
  47097. /**
  47098. * If the texture is a lumincance format
  47099. */
  47100. isLuminance: boolean;
  47101. /**
  47102. * If this is a cube texture
  47103. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47104. */
  47105. isCube: boolean;
  47106. /**
  47107. * If the texture is a compressed format eg. FOURCC_DXT1
  47108. */
  47109. isCompressed: boolean;
  47110. /**
  47111. * The dxgiFormat of the texture
  47112. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47113. */
  47114. dxgiFormat: number;
  47115. /**
  47116. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47117. */
  47118. textureType: number;
  47119. /**
  47120. * Sphericle polynomial created for the dds texture
  47121. */
  47122. sphericalPolynomial?: SphericalPolynomial;
  47123. }
  47124. /**
  47125. * Class used to provide DDS decompression tools
  47126. */
  47127. export class DDSTools {
  47128. /**
  47129. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47130. */
  47131. static StoreLODInAlphaChannel: boolean;
  47132. /**
  47133. * Gets DDS information from an array buffer
  47134. * @param arrayBuffer defines the array buffer to read data from
  47135. * @returns the DDS information
  47136. */
  47137. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47138. private static _FloatView;
  47139. private static _Int32View;
  47140. private static _ToHalfFloat;
  47141. private static _FromHalfFloat;
  47142. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47143. private static _GetHalfFloatRGBAArrayBuffer;
  47144. private static _GetFloatRGBAArrayBuffer;
  47145. private static _GetFloatAsUIntRGBAArrayBuffer;
  47146. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47147. private static _GetRGBAArrayBuffer;
  47148. private static _ExtractLongWordOrder;
  47149. private static _GetRGBArrayBuffer;
  47150. private static _GetLuminanceArrayBuffer;
  47151. /**
  47152. * Uploads DDS Levels to a Babylon Texture
  47153. * @hidden
  47154. */
  47155. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47156. }
  47157. interface Engine {
  47158. /**
  47159. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47160. * @param rootUrl defines the url where the file to load is located
  47161. * @param scene defines the current scene
  47162. * @param lodScale defines scale to apply to the mip map selection
  47163. * @param lodOffset defines offset to apply to the mip map selection
  47164. * @param onLoad defines an optional callback raised when the texture is loaded
  47165. * @param onError defines an optional callback raised if there is an issue to load the texture
  47166. * @param format defines the format of the data
  47167. * @param forcedExtension defines the extension to use to pick the right loader
  47168. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47169. * @returns the cube texture as an InternalTexture
  47170. */
  47171. 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;
  47172. }
  47173. }
  47174. declare module BABYLON {
  47175. /**
  47176. * Implementation of the DDS Texture Loader.
  47177. * @hidden
  47178. */
  47179. export class _DDSTextureLoader implements IInternalTextureLoader {
  47180. /**
  47181. * Defines wether the loader supports cascade loading the different faces.
  47182. */
  47183. readonly supportCascades: boolean;
  47184. /**
  47185. * This returns if the loader support the current file information.
  47186. * @param extension defines the file extension of the file being loaded
  47187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47188. * @param fallback defines the fallback internal texture if any
  47189. * @param isBase64 defines whether the texture is encoded as a base64
  47190. * @param isBuffer defines whether the texture data are stored as a buffer
  47191. * @returns true if the loader can load the specified file
  47192. */
  47193. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47194. /**
  47195. * Transform the url before loading if required.
  47196. * @param rootUrl the url of the texture
  47197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47198. * @returns the transformed texture
  47199. */
  47200. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47201. /**
  47202. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47203. * @param rootUrl the url of the texture
  47204. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47205. * @returns the fallback texture
  47206. */
  47207. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47208. /**
  47209. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47210. * @param data contains the texture data
  47211. * @param texture defines the BabylonJS internal texture
  47212. * @param createPolynomials will be true if polynomials have been requested
  47213. * @param onLoad defines the callback to trigger once the texture is ready
  47214. * @param onError defines the callback to trigger in case of error
  47215. */
  47216. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47217. /**
  47218. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47219. * @param data contains the texture data
  47220. * @param texture defines the BabylonJS internal texture
  47221. * @param callback defines the method to call once ready to upload
  47222. */
  47223. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47224. }
  47225. }
  47226. declare module BABYLON {
  47227. /** @hidden */
  47228. export var rgbdEncodePixelShader: {
  47229. name: string;
  47230. shader: string;
  47231. };
  47232. }
  47233. declare module BABYLON {
  47234. /**
  47235. * Raw texture data and descriptor sufficient for WebGL texture upload
  47236. */
  47237. export interface EnvironmentTextureInfo {
  47238. /**
  47239. * Version of the environment map
  47240. */
  47241. version: number;
  47242. /**
  47243. * Width of image
  47244. */
  47245. width: number;
  47246. /**
  47247. * Irradiance information stored in the file.
  47248. */
  47249. irradiance: any;
  47250. /**
  47251. * Specular information stored in the file.
  47252. */
  47253. specular: any;
  47254. }
  47255. /**
  47256. * Sets of helpers addressing the serialization and deserialization of environment texture
  47257. * stored in a BabylonJS env file.
  47258. * Those files are usually stored as .env files.
  47259. */
  47260. export class EnvironmentTextureTools {
  47261. /**
  47262. * Magic number identifying the env file.
  47263. */
  47264. private static _MagicBytes;
  47265. /**
  47266. * Gets the environment info from an env file.
  47267. * @param data The array buffer containing the .env bytes.
  47268. * @returns the environment file info (the json header) if successfully parsed.
  47269. */
  47270. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47271. /**
  47272. * Creates an environment texture from a loaded cube texture.
  47273. * @param texture defines the cube texture to convert in env file
  47274. * @return a promise containing the environment data if succesfull.
  47275. */
  47276. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47277. /**
  47278. * Creates a JSON representation of the spherical data.
  47279. * @param texture defines the texture containing the polynomials
  47280. * @return the JSON representation of the spherical info
  47281. */
  47282. private static _CreateEnvTextureIrradiance;
  47283. /**
  47284. * Uploads the texture info contained in the env file to the GPU.
  47285. * @param texture defines the internal texture to upload to
  47286. * @param arrayBuffer defines the buffer cotaining the data to load
  47287. * @param info defines the texture info retrieved through the GetEnvInfo method
  47288. * @returns a promise
  47289. */
  47290. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47291. /**
  47292. * Uploads the levels of image data to the GPU.
  47293. * @param texture defines the internal texture to upload to
  47294. * @param imageData defines the array buffer views of image data [mipmap][face]
  47295. * @returns a promise
  47296. */
  47297. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47298. /**
  47299. * Uploads spherical polynomials information to the texture.
  47300. * @param texture defines the texture we are trying to upload the information to
  47301. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47302. */
  47303. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47304. /** @hidden */
  47305. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47306. }
  47307. }
  47308. declare module BABYLON {
  47309. /**
  47310. * Implementation of the ENV Texture Loader.
  47311. * @hidden
  47312. */
  47313. export class _ENVTextureLoader implements IInternalTextureLoader {
  47314. /**
  47315. * Defines wether the loader supports cascade loading the different faces.
  47316. */
  47317. readonly supportCascades: boolean;
  47318. /**
  47319. * This returns if the loader support the current file information.
  47320. * @param extension defines the file extension of the file being loaded
  47321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47322. * @param fallback defines the fallback internal texture if any
  47323. * @param isBase64 defines whether the texture is encoded as a base64
  47324. * @param isBuffer defines whether the texture data are stored as a buffer
  47325. * @returns true if the loader can load the specified file
  47326. */
  47327. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47328. /**
  47329. * Transform the url before loading if required.
  47330. * @param rootUrl the url of the texture
  47331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47332. * @returns the transformed texture
  47333. */
  47334. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47335. /**
  47336. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47337. * @param rootUrl the url of the texture
  47338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47339. * @returns the fallback texture
  47340. */
  47341. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47342. /**
  47343. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47344. * @param data contains the texture data
  47345. * @param texture defines the BabylonJS internal texture
  47346. * @param createPolynomials will be true if polynomials have been requested
  47347. * @param onLoad defines the callback to trigger once the texture is ready
  47348. * @param onError defines the callback to trigger in case of error
  47349. */
  47350. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47351. /**
  47352. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47353. * @param data contains the texture data
  47354. * @param texture defines the BabylonJS internal texture
  47355. * @param callback defines the method to call once ready to upload
  47356. */
  47357. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47358. }
  47359. }
  47360. declare module BABYLON {
  47361. /**
  47362. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47363. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47364. */
  47365. export class KhronosTextureContainer {
  47366. /** contents of the KTX container file */
  47367. arrayBuffer: any;
  47368. private static HEADER_LEN;
  47369. private static COMPRESSED_2D;
  47370. private static COMPRESSED_3D;
  47371. private static TEX_2D;
  47372. private static TEX_3D;
  47373. /**
  47374. * Gets the openGL type
  47375. */
  47376. glType: number;
  47377. /**
  47378. * Gets the openGL type size
  47379. */
  47380. glTypeSize: number;
  47381. /**
  47382. * Gets the openGL format
  47383. */
  47384. glFormat: number;
  47385. /**
  47386. * Gets the openGL internal format
  47387. */
  47388. glInternalFormat: number;
  47389. /**
  47390. * Gets the base internal format
  47391. */
  47392. glBaseInternalFormat: number;
  47393. /**
  47394. * Gets image width in pixel
  47395. */
  47396. pixelWidth: number;
  47397. /**
  47398. * Gets image height in pixel
  47399. */
  47400. pixelHeight: number;
  47401. /**
  47402. * Gets image depth in pixels
  47403. */
  47404. pixelDepth: number;
  47405. /**
  47406. * Gets the number of array elements
  47407. */
  47408. numberOfArrayElements: number;
  47409. /**
  47410. * Gets the number of faces
  47411. */
  47412. numberOfFaces: number;
  47413. /**
  47414. * Gets the number of mipmap levels
  47415. */
  47416. numberOfMipmapLevels: number;
  47417. /**
  47418. * Gets the bytes of key value data
  47419. */
  47420. bytesOfKeyValueData: number;
  47421. /**
  47422. * Gets the load type
  47423. */
  47424. loadType: number;
  47425. /**
  47426. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47427. */
  47428. isInvalid: boolean;
  47429. /**
  47430. * Creates a new KhronosTextureContainer
  47431. * @param arrayBuffer contents of the KTX container file
  47432. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47433. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47434. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47435. */
  47436. constructor(
  47437. /** contents of the KTX container file */
  47438. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47439. /**
  47440. * Uploads KTX content to a Babylon Texture.
  47441. * It is assumed that the texture has already been created & is currently bound
  47442. * @hidden
  47443. */
  47444. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47445. private _upload2DCompressedLevels;
  47446. }
  47447. }
  47448. declare module BABYLON {
  47449. /**
  47450. * Implementation of the KTX Texture Loader.
  47451. * @hidden
  47452. */
  47453. export class _KTXTextureLoader implements IInternalTextureLoader {
  47454. /**
  47455. * Defines wether the loader supports cascade loading the different faces.
  47456. */
  47457. readonly supportCascades: boolean;
  47458. /**
  47459. * This returns if the loader support the current file information.
  47460. * @param extension defines the file extension of the file being loaded
  47461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47462. * @param fallback defines the fallback internal texture if any
  47463. * @param isBase64 defines whether the texture is encoded as a base64
  47464. * @param isBuffer defines whether the texture data are stored as a buffer
  47465. * @returns true if the loader can load the specified file
  47466. */
  47467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47468. /**
  47469. * Transform the url before loading if required.
  47470. * @param rootUrl the url of the texture
  47471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47472. * @returns the transformed texture
  47473. */
  47474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47475. /**
  47476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47477. * @param rootUrl the url of the texture
  47478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47479. * @returns the fallback texture
  47480. */
  47481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47482. /**
  47483. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47484. * @param data contains the texture data
  47485. * @param texture defines the BabylonJS internal texture
  47486. * @param createPolynomials will be true if polynomials have been requested
  47487. * @param onLoad defines the callback to trigger once the texture is ready
  47488. * @param onError defines the callback to trigger in case of error
  47489. */
  47490. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47491. /**
  47492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47493. * @param data contains the texture data
  47494. * @param texture defines the BabylonJS internal texture
  47495. * @param callback defines the method to call once ready to upload
  47496. */
  47497. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47498. }
  47499. }
  47500. declare module BABYLON {
  47501. /**
  47502. * Options for the default xr helper
  47503. */
  47504. export class WebXRDefaultExperienceOptions {
  47505. /**
  47506. * Floor meshes that should be used for teleporting
  47507. */
  47508. floorMeshes: Array<AbstractMesh>;
  47509. }
  47510. /**
  47511. * Default experience which provides a similar setup to the previous webVRExperience
  47512. */
  47513. export class WebXRDefaultExperience {
  47514. /**
  47515. * Base experience
  47516. */
  47517. baseExperience: WebXRExperienceHelper;
  47518. /**
  47519. * Input experience extension
  47520. */
  47521. input: WebXRInput;
  47522. /**
  47523. * Loads the controller models
  47524. */
  47525. controllerModelLoader: WebXRControllerModelLoader;
  47526. /**
  47527. * Enables laser pointer and selection
  47528. */
  47529. pointerSelection: WebXRControllerPointerSelection;
  47530. /**
  47531. * Enables teleportation
  47532. */
  47533. teleportation: WebXRControllerTeleportation;
  47534. /**
  47535. * Enables ui for enetering/exiting xr
  47536. */
  47537. enterExitUI: WebXREnterExitUI;
  47538. /**
  47539. * Default output canvas xr should render to
  47540. */
  47541. outputCanvas: WebXRManagedOutputCanvas;
  47542. /**
  47543. * Creates the default xr experience
  47544. * @param scene scene
  47545. * @param options options for basic configuration
  47546. * @returns resulting WebXRDefaultExperience
  47547. */
  47548. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47549. private constructor();
  47550. /**
  47551. * DIsposes of the experience helper
  47552. */
  47553. dispose(): void;
  47554. }
  47555. }
  47556. declare module BABYLON {
  47557. /** @hidden */
  47558. export var _forceSceneHelpersToBundle: boolean;
  47559. interface Scene {
  47560. /**
  47561. * Creates a default light for the scene.
  47562. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47563. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47564. */
  47565. createDefaultLight(replace?: boolean): void;
  47566. /**
  47567. * Creates a default camera for the scene.
  47568. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47569. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47570. * @param replace has default false, when true replaces the active camera in the scene
  47571. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47572. */
  47573. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47574. /**
  47575. * Creates a default camera and a default light.
  47576. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47577. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47578. * @param replace has the default false, when true replaces the active camera/light in the scene
  47579. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47580. */
  47581. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47582. /**
  47583. * Creates a new sky box
  47584. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47585. * @param environmentTexture defines the texture to use as environment texture
  47586. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47587. * @param scale defines the overall scale of the skybox
  47588. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47589. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47590. * @returns a new mesh holding the sky box
  47591. */
  47592. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47593. /**
  47594. * Creates a new environment
  47595. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47596. * @param options defines the options you can use to configure the environment
  47597. * @returns the new EnvironmentHelper
  47598. */
  47599. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47600. /**
  47601. * Creates a new VREXperienceHelper
  47602. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47603. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47604. * @returns a new VREXperienceHelper
  47605. */
  47606. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47607. /**
  47608. * Creates a new WebXRDefaultExperience
  47609. * @see http://doc.babylonjs.com/how_to/webxr
  47610. * @param options experience options
  47611. * @returns a promise for a new WebXRDefaultExperience
  47612. */
  47613. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47614. }
  47615. }
  47616. declare module BABYLON {
  47617. /**
  47618. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47619. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47620. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47622. */
  47623. export class VideoDome extends TransformNode {
  47624. /**
  47625. * Define the video source as a Monoscopic panoramic 360 video.
  47626. */
  47627. static readonly MODE_MONOSCOPIC: number;
  47628. /**
  47629. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47630. */
  47631. static readonly MODE_TOPBOTTOM: number;
  47632. /**
  47633. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47634. */
  47635. static readonly MODE_SIDEBYSIDE: number;
  47636. private _useDirectMapping;
  47637. /**
  47638. * The video texture being displayed on the sphere
  47639. */
  47640. protected _videoTexture: VideoTexture;
  47641. /**
  47642. * Gets the video texture being displayed on the sphere
  47643. */
  47644. readonly videoTexture: VideoTexture;
  47645. /**
  47646. * The skybox material
  47647. */
  47648. protected _material: BackgroundMaterial;
  47649. /**
  47650. * The surface used for the skybox
  47651. */
  47652. protected _mesh: Mesh;
  47653. /**
  47654. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47655. * Also see the options.resolution property.
  47656. */
  47657. fovMultiplier: number;
  47658. private _videoMode;
  47659. /**
  47660. * Gets or set the current video mode for the video. It can be:
  47661. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47662. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47663. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47664. */
  47665. videoMode: number;
  47666. /**
  47667. * Oberserver used in Stereoscopic VR Mode.
  47668. */
  47669. private _onBeforeCameraRenderObserver;
  47670. /**
  47671. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47672. * @param name Element's name, child elements will append suffixes for their own names.
  47673. * @param urlsOrVideo defines the url(s) or the video element to use
  47674. * @param options An object containing optional or exposed sub element properties
  47675. */
  47676. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47677. resolution?: number;
  47678. clickToPlay?: boolean;
  47679. autoPlay?: boolean;
  47680. loop?: boolean;
  47681. size?: number;
  47682. poster?: string;
  47683. faceForward?: boolean;
  47684. useDirectMapping?: boolean;
  47685. }, scene: Scene);
  47686. private _changeVideoMode;
  47687. /**
  47688. * Releases resources associated with this node.
  47689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47691. */
  47692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47693. }
  47694. }
  47695. declare module BABYLON {
  47696. /**
  47697. * This class can be used to get instrumentation data from a Babylon engine
  47698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47699. */
  47700. export class EngineInstrumentation implements IDisposable {
  47701. /**
  47702. * Define the instrumented engine.
  47703. */
  47704. engine: Engine;
  47705. private _captureGPUFrameTime;
  47706. private _gpuFrameTimeToken;
  47707. private _gpuFrameTime;
  47708. private _captureShaderCompilationTime;
  47709. private _shaderCompilationTime;
  47710. private _onBeginFrameObserver;
  47711. private _onEndFrameObserver;
  47712. private _onBeforeShaderCompilationObserver;
  47713. private _onAfterShaderCompilationObserver;
  47714. /**
  47715. * Gets the perf counter used for GPU frame time
  47716. */
  47717. readonly gpuFrameTimeCounter: PerfCounter;
  47718. /**
  47719. * Gets the GPU frame time capture status
  47720. */
  47721. /**
  47722. * Enable or disable the GPU frame time capture
  47723. */
  47724. captureGPUFrameTime: boolean;
  47725. /**
  47726. * Gets the perf counter used for shader compilation time
  47727. */
  47728. readonly shaderCompilationTimeCounter: PerfCounter;
  47729. /**
  47730. * Gets the shader compilation time capture status
  47731. */
  47732. /**
  47733. * Enable or disable the shader compilation time capture
  47734. */
  47735. captureShaderCompilationTime: boolean;
  47736. /**
  47737. * Instantiates a new engine instrumentation.
  47738. * This class can be used to get instrumentation data from a Babylon engine
  47739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47740. * @param engine Defines the engine to instrument
  47741. */
  47742. constructor(
  47743. /**
  47744. * Define the instrumented engine.
  47745. */
  47746. engine: Engine);
  47747. /**
  47748. * Dispose and release associated resources.
  47749. */
  47750. dispose(): void;
  47751. }
  47752. }
  47753. declare module BABYLON {
  47754. /**
  47755. * This class can be used to get instrumentation data from a Babylon engine
  47756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47757. */
  47758. export class SceneInstrumentation implements IDisposable {
  47759. /**
  47760. * Defines the scene to instrument
  47761. */
  47762. scene: Scene;
  47763. private _captureActiveMeshesEvaluationTime;
  47764. private _activeMeshesEvaluationTime;
  47765. private _captureRenderTargetsRenderTime;
  47766. private _renderTargetsRenderTime;
  47767. private _captureFrameTime;
  47768. private _frameTime;
  47769. private _captureRenderTime;
  47770. private _renderTime;
  47771. private _captureInterFrameTime;
  47772. private _interFrameTime;
  47773. private _captureParticlesRenderTime;
  47774. private _particlesRenderTime;
  47775. private _captureSpritesRenderTime;
  47776. private _spritesRenderTime;
  47777. private _capturePhysicsTime;
  47778. private _physicsTime;
  47779. private _captureAnimationsTime;
  47780. private _animationsTime;
  47781. private _captureCameraRenderTime;
  47782. private _cameraRenderTime;
  47783. private _onBeforeActiveMeshesEvaluationObserver;
  47784. private _onAfterActiveMeshesEvaluationObserver;
  47785. private _onBeforeRenderTargetsRenderObserver;
  47786. private _onAfterRenderTargetsRenderObserver;
  47787. private _onAfterRenderObserver;
  47788. private _onBeforeDrawPhaseObserver;
  47789. private _onAfterDrawPhaseObserver;
  47790. private _onBeforeAnimationsObserver;
  47791. private _onBeforeParticlesRenderingObserver;
  47792. private _onAfterParticlesRenderingObserver;
  47793. private _onBeforeSpritesRenderingObserver;
  47794. private _onAfterSpritesRenderingObserver;
  47795. private _onBeforePhysicsObserver;
  47796. private _onAfterPhysicsObserver;
  47797. private _onAfterAnimationsObserver;
  47798. private _onBeforeCameraRenderObserver;
  47799. private _onAfterCameraRenderObserver;
  47800. /**
  47801. * Gets the perf counter used for active meshes evaluation time
  47802. */
  47803. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47804. /**
  47805. * Gets the active meshes evaluation time capture status
  47806. */
  47807. /**
  47808. * Enable or disable the active meshes evaluation time capture
  47809. */
  47810. captureActiveMeshesEvaluationTime: boolean;
  47811. /**
  47812. * Gets the perf counter used for render targets render time
  47813. */
  47814. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47815. /**
  47816. * Gets the render targets render time capture status
  47817. */
  47818. /**
  47819. * Enable or disable the render targets render time capture
  47820. */
  47821. captureRenderTargetsRenderTime: boolean;
  47822. /**
  47823. * Gets the perf counter used for particles render time
  47824. */
  47825. readonly particlesRenderTimeCounter: PerfCounter;
  47826. /**
  47827. * Gets the particles render time capture status
  47828. */
  47829. /**
  47830. * Enable or disable the particles render time capture
  47831. */
  47832. captureParticlesRenderTime: boolean;
  47833. /**
  47834. * Gets the perf counter used for sprites render time
  47835. */
  47836. readonly spritesRenderTimeCounter: PerfCounter;
  47837. /**
  47838. * Gets the sprites render time capture status
  47839. */
  47840. /**
  47841. * Enable or disable the sprites render time capture
  47842. */
  47843. captureSpritesRenderTime: boolean;
  47844. /**
  47845. * Gets the perf counter used for physics time
  47846. */
  47847. readonly physicsTimeCounter: PerfCounter;
  47848. /**
  47849. * Gets the physics time capture status
  47850. */
  47851. /**
  47852. * Enable or disable the physics time capture
  47853. */
  47854. capturePhysicsTime: boolean;
  47855. /**
  47856. * Gets the perf counter used for animations time
  47857. */
  47858. readonly animationsTimeCounter: PerfCounter;
  47859. /**
  47860. * Gets the animations time capture status
  47861. */
  47862. /**
  47863. * Enable or disable the animations time capture
  47864. */
  47865. captureAnimationsTime: boolean;
  47866. /**
  47867. * Gets the perf counter used for frame time capture
  47868. */
  47869. readonly frameTimeCounter: PerfCounter;
  47870. /**
  47871. * Gets the frame time capture status
  47872. */
  47873. /**
  47874. * Enable or disable the frame time capture
  47875. */
  47876. captureFrameTime: boolean;
  47877. /**
  47878. * Gets the perf counter used for inter-frames time capture
  47879. */
  47880. readonly interFrameTimeCounter: PerfCounter;
  47881. /**
  47882. * Gets the inter-frames time capture status
  47883. */
  47884. /**
  47885. * Enable or disable the inter-frames time capture
  47886. */
  47887. captureInterFrameTime: boolean;
  47888. /**
  47889. * Gets the perf counter used for render time capture
  47890. */
  47891. readonly renderTimeCounter: PerfCounter;
  47892. /**
  47893. * Gets the render time capture status
  47894. */
  47895. /**
  47896. * Enable or disable the render time capture
  47897. */
  47898. captureRenderTime: boolean;
  47899. /**
  47900. * Gets the perf counter used for camera render time capture
  47901. */
  47902. readonly cameraRenderTimeCounter: PerfCounter;
  47903. /**
  47904. * Gets the camera render time capture status
  47905. */
  47906. /**
  47907. * Enable or disable the camera render time capture
  47908. */
  47909. captureCameraRenderTime: boolean;
  47910. /**
  47911. * Gets the perf counter used for draw calls
  47912. */
  47913. readonly drawCallsCounter: PerfCounter;
  47914. /**
  47915. * Instantiates a new scene instrumentation.
  47916. * This class can be used to get instrumentation data from a Babylon engine
  47917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47918. * @param scene Defines the scene to instrument
  47919. */
  47920. constructor(
  47921. /**
  47922. * Defines the scene to instrument
  47923. */
  47924. scene: Scene);
  47925. /**
  47926. * Dispose and release associated resources.
  47927. */
  47928. dispose(): void;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /** @hidden */
  47933. export var glowMapGenerationPixelShader: {
  47934. name: string;
  47935. shader: string;
  47936. };
  47937. }
  47938. declare module BABYLON {
  47939. /** @hidden */
  47940. export var glowMapGenerationVertexShader: {
  47941. name: string;
  47942. shader: string;
  47943. };
  47944. }
  47945. declare module BABYLON {
  47946. /**
  47947. * Effect layer options. This helps customizing the behaviour
  47948. * of the effect layer.
  47949. */
  47950. export interface IEffectLayerOptions {
  47951. /**
  47952. * Multiplication factor apply to the canvas size to compute the render target size
  47953. * used to generated the objects (the smaller the faster).
  47954. */
  47955. mainTextureRatio: number;
  47956. /**
  47957. * Enforces a fixed size texture to ensure effect stability across devices.
  47958. */
  47959. mainTextureFixedSize?: number;
  47960. /**
  47961. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47962. */
  47963. alphaBlendingMode: number;
  47964. /**
  47965. * The camera attached to the layer.
  47966. */
  47967. camera: Nullable<Camera>;
  47968. /**
  47969. * The rendering group to draw the layer in.
  47970. */
  47971. renderingGroupId: number;
  47972. }
  47973. /**
  47974. * The effect layer Helps adding post process effect blended with the main pass.
  47975. *
  47976. * This can be for instance use to generate glow or higlight effects on the scene.
  47977. *
  47978. * The effect layer class can not be used directly and is intented to inherited from to be
  47979. * customized per effects.
  47980. */
  47981. export abstract class EffectLayer {
  47982. private _vertexBuffers;
  47983. private _indexBuffer;
  47984. private _cachedDefines;
  47985. private _effectLayerMapGenerationEffect;
  47986. private _effectLayerOptions;
  47987. private _mergeEffect;
  47988. protected _scene: Scene;
  47989. protected _engine: Engine;
  47990. protected _maxSize: number;
  47991. protected _mainTextureDesiredSize: ISize;
  47992. protected _mainTexture: RenderTargetTexture;
  47993. protected _shouldRender: boolean;
  47994. protected _postProcesses: PostProcess[];
  47995. protected _textures: BaseTexture[];
  47996. protected _emissiveTextureAndColor: {
  47997. texture: Nullable<BaseTexture>;
  47998. color: Color4;
  47999. };
  48000. /**
  48001. * The name of the layer
  48002. */
  48003. name: string;
  48004. /**
  48005. * The clear color of the texture used to generate the glow map.
  48006. */
  48007. neutralColor: Color4;
  48008. /**
  48009. * Specifies wether the highlight layer is enabled or not.
  48010. */
  48011. isEnabled: boolean;
  48012. /**
  48013. * Gets the camera attached to the layer.
  48014. */
  48015. readonly camera: Nullable<Camera>;
  48016. /**
  48017. * Gets the rendering group id the layer should render in.
  48018. */
  48019. renderingGroupId: number;
  48020. /**
  48021. * An event triggered when the effect layer has been disposed.
  48022. */
  48023. onDisposeObservable: Observable<EffectLayer>;
  48024. /**
  48025. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48026. */
  48027. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48028. /**
  48029. * An event triggered when the generated texture is being merged in the scene.
  48030. */
  48031. onBeforeComposeObservable: Observable<EffectLayer>;
  48032. /**
  48033. * An event triggered when the generated texture has been merged in the scene.
  48034. */
  48035. onAfterComposeObservable: Observable<EffectLayer>;
  48036. /**
  48037. * An event triggered when the efffect layer changes its size.
  48038. */
  48039. onSizeChangedObservable: Observable<EffectLayer>;
  48040. /** @hidden */
  48041. static _SceneComponentInitialization: (scene: Scene) => void;
  48042. /**
  48043. * Instantiates a new effect Layer and references it in the scene.
  48044. * @param name The name of the layer
  48045. * @param scene The scene to use the layer in
  48046. */
  48047. constructor(
  48048. /** The Friendly of the effect in the scene */
  48049. name: string, scene: Scene);
  48050. /**
  48051. * Get the effect name of the layer.
  48052. * @return The effect name
  48053. */
  48054. abstract getEffectName(): string;
  48055. /**
  48056. * Checks for the readiness of the element composing the layer.
  48057. * @param subMesh the mesh to check for
  48058. * @param useInstances specify wether or not to use instances to render the mesh
  48059. * @return true if ready otherwise, false
  48060. */
  48061. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48062. /**
  48063. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48064. * @returns true if the effect requires stencil during the main canvas render pass.
  48065. */
  48066. abstract needStencil(): boolean;
  48067. /**
  48068. * Create the merge effect. This is the shader use to blit the information back
  48069. * to the main canvas at the end of the scene rendering.
  48070. * @returns The effect containing the shader used to merge the effect on the main canvas
  48071. */
  48072. protected abstract _createMergeEffect(): Effect;
  48073. /**
  48074. * Creates the render target textures and post processes used in the effect layer.
  48075. */
  48076. protected abstract _createTextureAndPostProcesses(): void;
  48077. /**
  48078. * Implementation specific of rendering the generating effect on the main canvas.
  48079. * @param effect The effect used to render through
  48080. */
  48081. protected abstract _internalRender(effect: Effect): void;
  48082. /**
  48083. * Sets the required values for both the emissive texture and and the main color.
  48084. */
  48085. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48086. /**
  48087. * Free any resources and references associated to a mesh.
  48088. * Internal use
  48089. * @param mesh The mesh to free.
  48090. */
  48091. abstract _disposeMesh(mesh: Mesh): void;
  48092. /**
  48093. * Serializes this layer (Glow or Highlight for example)
  48094. * @returns a serialized layer object
  48095. */
  48096. abstract serialize?(): any;
  48097. /**
  48098. * Initializes the effect layer with the required options.
  48099. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48100. */
  48101. protected _init(options: Partial<IEffectLayerOptions>): void;
  48102. /**
  48103. * Generates the index buffer of the full screen quad blending to the main canvas.
  48104. */
  48105. private _generateIndexBuffer;
  48106. /**
  48107. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48108. */
  48109. private _generateVertexBuffer;
  48110. /**
  48111. * Sets the main texture desired size which is the closest power of two
  48112. * of the engine canvas size.
  48113. */
  48114. private _setMainTextureSize;
  48115. /**
  48116. * Creates the main texture for the effect layer.
  48117. */
  48118. protected _createMainTexture(): void;
  48119. /**
  48120. * Adds specific effects defines.
  48121. * @param defines The defines to add specifics to.
  48122. */
  48123. protected _addCustomEffectDefines(defines: string[]): void;
  48124. /**
  48125. * Checks for the readiness of the element composing the layer.
  48126. * @param subMesh the mesh to check for
  48127. * @param useInstances specify wether or not to use instances to render the mesh
  48128. * @param emissiveTexture the associated emissive texture used to generate the glow
  48129. * @return true if ready otherwise, false
  48130. */
  48131. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48132. /**
  48133. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48134. */
  48135. render(): void;
  48136. /**
  48137. * Determine if a given mesh will be used in the current effect.
  48138. * @param mesh mesh to test
  48139. * @returns true if the mesh will be used
  48140. */
  48141. hasMesh(mesh: AbstractMesh): boolean;
  48142. /**
  48143. * Returns true if the layer contains information to display, otherwise false.
  48144. * @returns true if the glow layer should be rendered
  48145. */
  48146. shouldRender(): boolean;
  48147. /**
  48148. * Returns true if the mesh should render, otherwise false.
  48149. * @param mesh The mesh to render
  48150. * @returns true if it should render otherwise false
  48151. */
  48152. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48153. /**
  48154. * Returns true if the mesh can be rendered, otherwise false.
  48155. * @param mesh The mesh to render
  48156. * @param material The material used on the mesh
  48157. * @returns true if it can be rendered otherwise false
  48158. */
  48159. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48160. /**
  48161. * Returns true if the mesh should render, otherwise false.
  48162. * @param mesh The mesh to render
  48163. * @returns true if it should render otherwise false
  48164. */
  48165. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48166. /**
  48167. * Renders the submesh passed in parameter to the generation map.
  48168. */
  48169. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48170. /**
  48171. * Rebuild the required buffers.
  48172. * @hidden Internal use only.
  48173. */
  48174. _rebuild(): void;
  48175. /**
  48176. * Dispose only the render target textures and post process.
  48177. */
  48178. private _disposeTextureAndPostProcesses;
  48179. /**
  48180. * Dispose the highlight layer and free resources.
  48181. */
  48182. dispose(): void;
  48183. /**
  48184. * Gets the class name of the effect layer
  48185. * @returns the string with the class name of the effect layer
  48186. */
  48187. getClassName(): string;
  48188. /**
  48189. * Creates an effect layer from parsed effect layer data
  48190. * @param parsedEffectLayer defines effect layer data
  48191. * @param scene defines the current scene
  48192. * @param rootUrl defines the root URL containing the effect layer information
  48193. * @returns a parsed effect Layer
  48194. */
  48195. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48196. }
  48197. }
  48198. declare module BABYLON {
  48199. interface AbstractScene {
  48200. /**
  48201. * The list of effect layers (highlights/glow) added to the scene
  48202. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48203. * @see http://doc.babylonjs.com/how_to/glow_layer
  48204. */
  48205. effectLayers: Array<EffectLayer>;
  48206. /**
  48207. * Removes the given effect layer from this scene.
  48208. * @param toRemove defines the effect layer to remove
  48209. * @returns the index of the removed effect layer
  48210. */
  48211. removeEffectLayer(toRemove: EffectLayer): number;
  48212. /**
  48213. * Adds the given effect layer to this scene
  48214. * @param newEffectLayer defines the effect layer to add
  48215. */
  48216. addEffectLayer(newEffectLayer: EffectLayer): void;
  48217. }
  48218. /**
  48219. * Defines the layer scene component responsible to manage any effect layers
  48220. * in a given scene.
  48221. */
  48222. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48223. /**
  48224. * The component name helpfull to identify the component in the list of scene components.
  48225. */
  48226. readonly name: string;
  48227. /**
  48228. * The scene the component belongs to.
  48229. */
  48230. scene: Scene;
  48231. private _engine;
  48232. private _renderEffects;
  48233. private _needStencil;
  48234. private _previousStencilState;
  48235. /**
  48236. * Creates a new instance of the component for the given scene
  48237. * @param scene Defines the scene to register the component in
  48238. */
  48239. constructor(scene: Scene);
  48240. /**
  48241. * Registers the component in a given scene
  48242. */
  48243. register(): void;
  48244. /**
  48245. * Rebuilds the elements related to this component in case of
  48246. * context lost for instance.
  48247. */
  48248. rebuild(): void;
  48249. /**
  48250. * Serializes the component data to the specified json object
  48251. * @param serializationObject The object to serialize to
  48252. */
  48253. serialize(serializationObject: any): void;
  48254. /**
  48255. * Adds all the elements from the container to the scene
  48256. * @param container the container holding the elements
  48257. */
  48258. addFromContainer(container: AbstractScene): void;
  48259. /**
  48260. * Removes all the elements in the container from the scene
  48261. * @param container contains the elements to remove
  48262. * @param dispose if the removed element should be disposed (default: false)
  48263. */
  48264. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48265. /**
  48266. * Disposes the component and the associated ressources.
  48267. */
  48268. dispose(): void;
  48269. private _isReadyForMesh;
  48270. private _renderMainTexture;
  48271. private _setStencil;
  48272. private _setStencilBack;
  48273. private _draw;
  48274. private _drawCamera;
  48275. private _drawRenderingGroup;
  48276. }
  48277. }
  48278. declare module BABYLON {
  48279. /** @hidden */
  48280. export var glowMapMergePixelShader: {
  48281. name: string;
  48282. shader: string;
  48283. };
  48284. }
  48285. declare module BABYLON {
  48286. /** @hidden */
  48287. export var glowMapMergeVertexShader: {
  48288. name: string;
  48289. shader: string;
  48290. };
  48291. }
  48292. declare module BABYLON {
  48293. interface AbstractScene {
  48294. /**
  48295. * Return a the first highlight layer of the scene with a given name.
  48296. * @param name The name of the highlight layer to look for.
  48297. * @return The highlight layer if found otherwise null.
  48298. */
  48299. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48300. }
  48301. /**
  48302. * Glow layer options. This helps customizing the behaviour
  48303. * of the glow layer.
  48304. */
  48305. export interface IGlowLayerOptions {
  48306. /**
  48307. * Multiplication factor apply to the canvas size to compute the render target size
  48308. * used to generated the glowing objects (the smaller the faster).
  48309. */
  48310. mainTextureRatio: number;
  48311. /**
  48312. * Enforces a fixed size texture to ensure resize independant blur.
  48313. */
  48314. mainTextureFixedSize?: number;
  48315. /**
  48316. * How big is the kernel of the blur texture.
  48317. */
  48318. blurKernelSize: number;
  48319. /**
  48320. * The camera attached to the layer.
  48321. */
  48322. camera: Nullable<Camera>;
  48323. /**
  48324. * Enable MSAA by chosing the number of samples.
  48325. */
  48326. mainTextureSamples?: number;
  48327. /**
  48328. * The rendering group to draw the layer in.
  48329. */
  48330. renderingGroupId: number;
  48331. }
  48332. /**
  48333. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48334. *
  48335. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48336. * glowy meshes to your scene.
  48337. *
  48338. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48339. */
  48340. export class GlowLayer extends EffectLayer {
  48341. /**
  48342. * Effect Name of the layer.
  48343. */
  48344. static readonly EffectName: string;
  48345. /**
  48346. * The default blur kernel size used for the glow.
  48347. */
  48348. static DefaultBlurKernelSize: number;
  48349. /**
  48350. * The default texture size ratio used for the glow.
  48351. */
  48352. static DefaultTextureRatio: number;
  48353. /**
  48354. * Sets the kernel size of the blur.
  48355. */
  48356. /**
  48357. * Gets the kernel size of the blur.
  48358. */
  48359. blurKernelSize: number;
  48360. /**
  48361. * Sets the glow intensity.
  48362. */
  48363. /**
  48364. * Gets the glow intensity.
  48365. */
  48366. intensity: number;
  48367. private _options;
  48368. private _intensity;
  48369. private _horizontalBlurPostprocess1;
  48370. private _verticalBlurPostprocess1;
  48371. private _horizontalBlurPostprocess2;
  48372. private _verticalBlurPostprocess2;
  48373. private _blurTexture1;
  48374. private _blurTexture2;
  48375. private _postProcesses1;
  48376. private _postProcesses2;
  48377. private _includedOnlyMeshes;
  48378. private _excludedMeshes;
  48379. /**
  48380. * Callback used to let the user override the color selection on a per mesh basis
  48381. */
  48382. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48383. /**
  48384. * Callback used to let the user override the texture selection on a per mesh basis
  48385. */
  48386. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48387. /**
  48388. * Instantiates a new glow Layer and references it to the scene.
  48389. * @param name The name of the layer
  48390. * @param scene The scene to use the layer in
  48391. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48392. */
  48393. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48394. /**
  48395. * Get the effect name of the layer.
  48396. * @return The effect name
  48397. */
  48398. getEffectName(): string;
  48399. /**
  48400. * Create the merge effect. This is the shader use to blit the information back
  48401. * to the main canvas at the end of the scene rendering.
  48402. */
  48403. protected _createMergeEffect(): Effect;
  48404. /**
  48405. * Creates the render target textures and post processes used in the glow layer.
  48406. */
  48407. protected _createTextureAndPostProcesses(): void;
  48408. /**
  48409. * Checks for the readiness of the element composing the layer.
  48410. * @param subMesh the mesh to check for
  48411. * @param useInstances specify wether or not to use instances to render the mesh
  48412. * @param emissiveTexture the associated emissive texture used to generate the glow
  48413. * @return true if ready otherwise, false
  48414. */
  48415. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48416. /**
  48417. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48418. */
  48419. needStencil(): boolean;
  48420. /**
  48421. * Returns true if the mesh can be rendered, otherwise false.
  48422. * @param mesh The mesh to render
  48423. * @param material The material used on the mesh
  48424. * @returns true if it can be rendered otherwise false
  48425. */
  48426. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48427. /**
  48428. * Implementation specific of rendering the generating effect on the main canvas.
  48429. * @param effect The effect used to render through
  48430. */
  48431. protected _internalRender(effect: Effect): void;
  48432. /**
  48433. * Sets the required values for both the emissive texture and and the main color.
  48434. */
  48435. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48436. /**
  48437. * Returns true if the mesh should render, otherwise false.
  48438. * @param mesh The mesh to render
  48439. * @returns true if it should render otherwise false
  48440. */
  48441. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48442. /**
  48443. * Adds specific effects defines.
  48444. * @param defines The defines to add specifics to.
  48445. */
  48446. protected _addCustomEffectDefines(defines: string[]): void;
  48447. /**
  48448. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48449. * @param mesh The mesh to exclude from the glow layer
  48450. */
  48451. addExcludedMesh(mesh: Mesh): void;
  48452. /**
  48453. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48454. * @param mesh The mesh to remove
  48455. */
  48456. removeExcludedMesh(mesh: Mesh): void;
  48457. /**
  48458. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48459. * @param mesh The mesh to include in the glow layer
  48460. */
  48461. addIncludedOnlyMesh(mesh: Mesh): void;
  48462. /**
  48463. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48464. * @param mesh The mesh to remove
  48465. */
  48466. removeIncludedOnlyMesh(mesh: Mesh): void;
  48467. /**
  48468. * Determine if a given mesh will be used in the glow layer
  48469. * @param mesh The mesh to test
  48470. * @returns true if the mesh will be highlighted by the current glow layer
  48471. */
  48472. hasMesh(mesh: AbstractMesh): boolean;
  48473. /**
  48474. * Free any resources and references associated to a mesh.
  48475. * Internal use
  48476. * @param mesh The mesh to free.
  48477. * @hidden
  48478. */
  48479. _disposeMesh(mesh: Mesh): void;
  48480. /**
  48481. * Gets the class name of the effect layer
  48482. * @returns the string with the class name of the effect layer
  48483. */
  48484. getClassName(): string;
  48485. /**
  48486. * Serializes this glow layer
  48487. * @returns a serialized glow layer object
  48488. */
  48489. serialize(): any;
  48490. /**
  48491. * Creates a Glow Layer from parsed glow layer data
  48492. * @param parsedGlowLayer defines glow layer data
  48493. * @param scene defines the current scene
  48494. * @param rootUrl defines the root URL containing the glow layer information
  48495. * @returns a parsed Glow Layer
  48496. */
  48497. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48498. }
  48499. }
  48500. declare module BABYLON {
  48501. /** @hidden */
  48502. export var glowBlurPostProcessPixelShader: {
  48503. name: string;
  48504. shader: string;
  48505. };
  48506. }
  48507. declare module BABYLON {
  48508. interface AbstractScene {
  48509. /**
  48510. * Return a the first highlight layer of the scene with a given name.
  48511. * @param name The name of the highlight layer to look for.
  48512. * @return The highlight layer if found otherwise null.
  48513. */
  48514. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48515. }
  48516. /**
  48517. * Highlight layer options. This helps customizing the behaviour
  48518. * of the highlight layer.
  48519. */
  48520. export interface IHighlightLayerOptions {
  48521. /**
  48522. * Multiplication factor apply to the canvas size to compute the render target size
  48523. * used to generated the glowing objects (the smaller the faster).
  48524. */
  48525. mainTextureRatio: number;
  48526. /**
  48527. * Enforces a fixed size texture to ensure resize independant blur.
  48528. */
  48529. mainTextureFixedSize?: number;
  48530. /**
  48531. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48532. * of the picture to blur (the smaller the faster).
  48533. */
  48534. blurTextureSizeRatio: number;
  48535. /**
  48536. * How big in texel of the blur texture is the vertical blur.
  48537. */
  48538. blurVerticalSize: number;
  48539. /**
  48540. * How big in texel of the blur texture is the horizontal blur.
  48541. */
  48542. blurHorizontalSize: number;
  48543. /**
  48544. * Alpha blending mode used to apply the blur. Default is combine.
  48545. */
  48546. alphaBlendingMode: number;
  48547. /**
  48548. * The camera attached to the layer.
  48549. */
  48550. camera: Nullable<Camera>;
  48551. /**
  48552. * Should we display highlight as a solid stroke?
  48553. */
  48554. isStroke?: boolean;
  48555. /**
  48556. * The rendering group to draw the layer in.
  48557. */
  48558. renderingGroupId: number;
  48559. }
  48560. /**
  48561. * The highlight layer Helps adding a glow effect around a mesh.
  48562. *
  48563. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48564. * glowy meshes to your scene.
  48565. *
  48566. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48567. */
  48568. export class HighlightLayer extends EffectLayer {
  48569. name: string;
  48570. /**
  48571. * Effect Name of the highlight layer.
  48572. */
  48573. static readonly EffectName: string;
  48574. /**
  48575. * The neutral color used during the preparation of the glow effect.
  48576. * This is black by default as the blend operation is a blend operation.
  48577. */
  48578. static NeutralColor: Color4;
  48579. /**
  48580. * Stencil value used for glowing meshes.
  48581. */
  48582. static GlowingMeshStencilReference: number;
  48583. /**
  48584. * Stencil value used for the other meshes in the scene.
  48585. */
  48586. static NormalMeshStencilReference: number;
  48587. /**
  48588. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48589. */
  48590. innerGlow: boolean;
  48591. /**
  48592. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48593. */
  48594. outerGlow: boolean;
  48595. /**
  48596. * Specifies the horizontal size of the blur.
  48597. */
  48598. /**
  48599. * Gets the horizontal size of the blur.
  48600. */
  48601. blurHorizontalSize: number;
  48602. /**
  48603. * Specifies the vertical size of the blur.
  48604. */
  48605. /**
  48606. * Gets the vertical size of the blur.
  48607. */
  48608. blurVerticalSize: number;
  48609. /**
  48610. * An event triggered when the highlight layer is being blurred.
  48611. */
  48612. onBeforeBlurObservable: Observable<HighlightLayer>;
  48613. /**
  48614. * An event triggered when the highlight layer has been blurred.
  48615. */
  48616. onAfterBlurObservable: Observable<HighlightLayer>;
  48617. private _instanceGlowingMeshStencilReference;
  48618. private _options;
  48619. private _downSamplePostprocess;
  48620. private _horizontalBlurPostprocess;
  48621. private _verticalBlurPostprocess;
  48622. private _blurTexture;
  48623. private _meshes;
  48624. private _excludedMeshes;
  48625. /**
  48626. * Instantiates a new highlight Layer and references it to the scene..
  48627. * @param name The name of the layer
  48628. * @param scene The scene to use the layer in
  48629. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48630. */
  48631. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48632. /**
  48633. * Get the effect name of the layer.
  48634. * @return The effect name
  48635. */
  48636. getEffectName(): string;
  48637. /**
  48638. * Create the merge effect. This is the shader use to blit the information back
  48639. * to the main canvas at the end of the scene rendering.
  48640. */
  48641. protected _createMergeEffect(): Effect;
  48642. /**
  48643. * Creates the render target textures and post processes used in the highlight layer.
  48644. */
  48645. protected _createTextureAndPostProcesses(): void;
  48646. /**
  48647. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48648. */
  48649. needStencil(): boolean;
  48650. /**
  48651. * Checks for the readiness of the element composing the layer.
  48652. * @param subMesh the mesh to check for
  48653. * @param useInstances specify wether or not to use instances to render the mesh
  48654. * @param emissiveTexture the associated emissive texture used to generate the glow
  48655. * @return true if ready otherwise, false
  48656. */
  48657. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48658. /**
  48659. * Implementation specific of rendering the generating effect on the main canvas.
  48660. * @param effect The effect used to render through
  48661. */
  48662. protected _internalRender(effect: Effect): void;
  48663. /**
  48664. * Returns true if the layer contains information to display, otherwise false.
  48665. */
  48666. shouldRender(): boolean;
  48667. /**
  48668. * Returns true if the mesh should render, otherwise false.
  48669. * @param mesh The mesh to render
  48670. * @returns true if it should render otherwise false
  48671. */
  48672. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48673. /**
  48674. * Sets the required values for both the emissive texture and and the main color.
  48675. */
  48676. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48677. /**
  48678. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48679. * @param mesh The mesh to exclude from the highlight layer
  48680. */
  48681. addExcludedMesh(mesh: Mesh): void;
  48682. /**
  48683. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48684. * @param mesh The mesh to highlight
  48685. */
  48686. removeExcludedMesh(mesh: Mesh): void;
  48687. /**
  48688. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48689. * @param mesh mesh to test
  48690. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48691. */
  48692. hasMesh(mesh: AbstractMesh): boolean;
  48693. /**
  48694. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48695. * @param mesh The mesh to highlight
  48696. * @param color The color of the highlight
  48697. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48698. */
  48699. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48700. /**
  48701. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48702. * @param mesh The mesh to highlight
  48703. */
  48704. removeMesh(mesh: Mesh): void;
  48705. /**
  48706. * Force the stencil to the normal expected value for none glowing parts
  48707. */
  48708. private _defaultStencilReference;
  48709. /**
  48710. * Free any resources and references associated to a mesh.
  48711. * Internal use
  48712. * @param mesh The mesh to free.
  48713. * @hidden
  48714. */
  48715. _disposeMesh(mesh: Mesh): void;
  48716. /**
  48717. * Dispose the highlight layer and free resources.
  48718. */
  48719. dispose(): void;
  48720. /**
  48721. * Gets the class name of the effect layer
  48722. * @returns the string with the class name of the effect layer
  48723. */
  48724. getClassName(): string;
  48725. /**
  48726. * Serializes this Highlight layer
  48727. * @returns a serialized Highlight layer object
  48728. */
  48729. serialize(): any;
  48730. /**
  48731. * Creates a Highlight layer from parsed Highlight layer data
  48732. * @param parsedHightlightLayer defines the Highlight layer data
  48733. * @param scene defines the current scene
  48734. * @param rootUrl defines the root URL containing the Highlight layer information
  48735. * @returns a parsed Highlight layer
  48736. */
  48737. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48738. }
  48739. }
  48740. declare module BABYLON {
  48741. interface AbstractScene {
  48742. /**
  48743. * The list of layers (background and foreground) of the scene
  48744. */
  48745. layers: Array<Layer>;
  48746. }
  48747. /**
  48748. * Defines the layer scene component responsible to manage any layers
  48749. * in a given scene.
  48750. */
  48751. export class LayerSceneComponent implements ISceneComponent {
  48752. /**
  48753. * The component name helpfull to identify the component in the list of scene components.
  48754. */
  48755. readonly name: string;
  48756. /**
  48757. * The scene the component belongs to.
  48758. */
  48759. scene: Scene;
  48760. private _engine;
  48761. /**
  48762. * Creates a new instance of the component for the given scene
  48763. * @param scene Defines the scene to register the component in
  48764. */
  48765. constructor(scene: Scene);
  48766. /**
  48767. * Registers the component in a given scene
  48768. */
  48769. register(): void;
  48770. /**
  48771. * Rebuilds the elements related to this component in case of
  48772. * context lost for instance.
  48773. */
  48774. rebuild(): void;
  48775. /**
  48776. * Disposes the component and the associated ressources.
  48777. */
  48778. dispose(): void;
  48779. private _draw;
  48780. private _drawCameraPredicate;
  48781. private _drawCameraBackground;
  48782. private _drawCameraForeground;
  48783. private _drawRenderTargetPredicate;
  48784. private _drawRenderTargetBackground;
  48785. private _drawRenderTargetForeground;
  48786. /**
  48787. * Adds all the elements from the container to the scene
  48788. * @param container the container holding the elements
  48789. */
  48790. addFromContainer(container: AbstractScene): void;
  48791. /**
  48792. * Removes all the elements in the container from the scene
  48793. * @param container contains the elements to remove
  48794. * @param dispose if the removed element should be disposed (default: false)
  48795. */
  48796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48797. }
  48798. }
  48799. declare module BABYLON {
  48800. /** @hidden */
  48801. export var layerPixelShader: {
  48802. name: string;
  48803. shader: string;
  48804. };
  48805. }
  48806. declare module BABYLON {
  48807. /** @hidden */
  48808. export var layerVertexShader: {
  48809. name: string;
  48810. shader: string;
  48811. };
  48812. }
  48813. declare module BABYLON {
  48814. /**
  48815. * This represents a full screen 2d layer.
  48816. * This can be useful to display a picture in the background of your scene for instance.
  48817. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48818. */
  48819. export class Layer {
  48820. /**
  48821. * Define the name of the layer.
  48822. */
  48823. name: string;
  48824. /**
  48825. * Define the texture the layer should display.
  48826. */
  48827. texture: Nullable<Texture>;
  48828. /**
  48829. * Is the layer in background or foreground.
  48830. */
  48831. isBackground: boolean;
  48832. /**
  48833. * Define the color of the layer (instead of texture).
  48834. */
  48835. color: Color4;
  48836. /**
  48837. * Define the scale of the layer in order to zoom in out of the texture.
  48838. */
  48839. scale: Vector2;
  48840. /**
  48841. * Define an offset for the layer in order to shift the texture.
  48842. */
  48843. offset: Vector2;
  48844. /**
  48845. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48846. */
  48847. alphaBlendingMode: number;
  48848. /**
  48849. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48850. * Alpha test will not mix with the background color in case of transparency.
  48851. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48852. */
  48853. alphaTest: boolean;
  48854. /**
  48855. * Define a mask to restrict the layer to only some of the scene cameras.
  48856. */
  48857. layerMask: number;
  48858. /**
  48859. * Define the list of render target the layer is visible into.
  48860. */
  48861. renderTargetTextures: RenderTargetTexture[];
  48862. /**
  48863. * Define if the layer is only used in renderTarget or if it also
  48864. * renders in the main frame buffer of the canvas.
  48865. */
  48866. renderOnlyInRenderTargetTextures: boolean;
  48867. private _scene;
  48868. private _vertexBuffers;
  48869. private _indexBuffer;
  48870. private _effect;
  48871. private _alphaTestEffect;
  48872. /**
  48873. * An event triggered when the layer is disposed.
  48874. */
  48875. onDisposeObservable: Observable<Layer>;
  48876. private _onDisposeObserver;
  48877. /**
  48878. * Back compatibility with callback before the onDisposeObservable existed.
  48879. * The set callback will be triggered when the layer has been disposed.
  48880. */
  48881. onDispose: () => void;
  48882. /**
  48883. * An event triggered before rendering the scene
  48884. */
  48885. onBeforeRenderObservable: Observable<Layer>;
  48886. private _onBeforeRenderObserver;
  48887. /**
  48888. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48889. * The set callback will be triggered just before rendering the layer.
  48890. */
  48891. onBeforeRender: () => void;
  48892. /**
  48893. * An event triggered after rendering the scene
  48894. */
  48895. onAfterRenderObservable: Observable<Layer>;
  48896. private _onAfterRenderObserver;
  48897. /**
  48898. * Back compatibility with callback before the onAfterRenderObservable existed.
  48899. * The set callback will be triggered just after rendering the layer.
  48900. */
  48901. onAfterRender: () => void;
  48902. /**
  48903. * Instantiates a new layer.
  48904. * This represents a full screen 2d layer.
  48905. * This can be useful to display a picture in the background of your scene for instance.
  48906. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48907. * @param name Define the name of the layer in the scene
  48908. * @param imgUrl Define the url of the texture to display in the layer
  48909. * @param scene Define the scene the layer belongs to
  48910. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48911. * @param color Defines a color for the layer
  48912. */
  48913. constructor(
  48914. /**
  48915. * Define the name of the layer.
  48916. */
  48917. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48918. private _createIndexBuffer;
  48919. /** @hidden */
  48920. _rebuild(): void;
  48921. /**
  48922. * Renders the layer in the scene.
  48923. */
  48924. render(): void;
  48925. /**
  48926. * Disposes and releases the associated ressources.
  48927. */
  48928. dispose(): void;
  48929. }
  48930. }
  48931. declare module BABYLON {
  48932. /** @hidden */
  48933. export var lensFlarePixelShader: {
  48934. name: string;
  48935. shader: string;
  48936. };
  48937. }
  48938. declare module BABYLON {
  48939. /** @hidden */
  48940. export var lensFlareVertexShader: {
  48941. name: string;
  48942. shader: string;
  48943. };
  48944. }
  48945. declare module BABYLON {
  48946. /**
  48947. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48948. * It is usually composed of several `lensFlare`.
  48949. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48950. */
  48951. export class LensFlareSystem {
  48952. /**
  48953. * Define the name of the lens flare system
  48954. */
  48955. name: string;
  48956. /**
  48957. * List of lens flares used in this system.
  48958. */
  48959. lensFlares: LensFlare[];
  48960. /**
  48961. * Define a limit from the border the lens flare can be visible.
  48962. */
  48963. borderLimit: number;
  48964. /**
  48965. * Define a viewport border we do not want to see the lens flare in.
  48966. */
  48967. viewportBorder: number;
  48968. /**
  48969. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48970. */
  48971. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48972. /**
  48973. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48974. */
  48975. layerMask: number;
  48976. /**
  48977. * Define the id of the lens flare system in the scene.
  48978. * (equal to name by default)
  48979. */
  48980. id: string;
  48981. private _scene;
  48982. private _emitter;
  48983. private _vertexBuffers;
  48984. private _indexBuffer;
  48985. private _effect;
  48986. private _positionX;
  48987. private _positionY;
  48988. private _isEnabled;
  48989. /** @hidden */
  48990. static _SceneComponentInitialization: (scene: Scene) => void;
  48991. /**
  48992. * Instantiates a lens flare system.
  48993. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48994. * It is usually composed of several `lensFlare`.
  48995. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48996. * @param name Define the name of the lens flare system in the scene
  48997. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48998. * @param scene Define the scene the lens flare system belongs to
  48999. */
  49000. constructor(
  49001. /**
  49002. * Define the name of the lens flare system
  49003. */
  49004. name: string, emitter: any, scene: Scene);
  49005. /**
  49006. * Define if the lens flare system is enabled.
  49007. */
  49008. isEnabled: boolean;
  49009. /**
  49010. * Get the scene the effects belongs to.
  49011. * @returns the scene holding the lens flare system
  49012. */
  49013. getScene(): Scene;
  49014. /**
  49015. * Get the emitter of the lens flare system.
  49016. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49017. * @returns the emitter of the lens flare system
  49018. */
  49019. getEmitter(): any;
  49020. /**
  49021. * Set the emitter of the lens flare system.
  49022. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49023. * @param newEmitter Define the new emitter of the system
  49024. */
  49025. setEmitter(newEmitter: any): void;
  49026. /**
  49027. * Get the lens flare system emitter position.
  49028. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49029. * @returns the position
  49030. */
  49031. getEmitterPosition(): Vector3;
  49032. /**
  49033. * @hidden
  49034. */
  49035. computeEffectivePosition(globalViewport: Viewport): boolean;
  49036. /** @hidden */
  49037. _isVisible(): boolean;
  49038. /**
  49039. * @hidden
  49040. */
  49041. render(): boolean;
  49042. /**
  49043. * Dispose and release the lens flare with its associated resources.
  49044. */
  49045. dispose(): void;
  49046. /**
  49047. * Parse a lens flare system from a JSON repressentation
  49048. * @param parsedLensFlareSystem Define the JSON to parse
  49049. * @param scene Define the scene the parsed system should be instantiated in
  49050. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49051. * @returns the parsed system
  49052. */
  49053. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49054. /**
  49055. * Serialize the current Lens Flare System into a JSON representation.
  49056. * @returns the serialized JSON
  49057. */
  49058. serialize(): any;
  49059. }
  49060. }
  49061. declare module BABYLON {
  49062. /**
  49063. * This represents one of the lens effect in a `lensFlareSystem`.
  49064. * It controls one of the indiviual texture used in the effect.
  49065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49066. */
  49067. export class LensFlare {
  49068. /**
  49069. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49070. */
  49071. size: number;
  49072. /**
  49073. * 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.
  49074. */
  49075. position: number;
  49076. /**
  49077. * Define the lens color.
  49078. */
  49079. color: Color3;
  49080. /**
  49081. * Define the lens texture.
  49082. */
  49083. texture: Nullable<Texture>;
  49084. /**
  49085. * Define the alpha mode to render this particular lens.
  49086. */
  49087. alphaMode: number;
  49088. private _system;
  49089. /**
  49090. * Creates a new Lens Flare.
  49091. * This represents one of the lens effect in a `lensFlareSystem`.
  49092. * It controls one of the indiviual texture used in the effect.
  49093. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49094. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49095. * @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.
  49096. * @param color Define the lens color
  49097. * @param imgUrl Define the lens texture url
  49098. * @param system Define the `lensFlareSystem` this flare is part of
  49099. * @returns The newly created Lens Flare
  49100. */
  49101. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49102. /**
  49103. * Instantiates a new Lens Flare.
  49104. * This represents one of the lens effect in a `lensFlareSystem`.
  49105. * It controls one of the indiviual texture used in the effect.
  49106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49107. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49108. * @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.
  49109. * @param color Define the lens color
  49110. * @param imgUrl Define the lens texture url
  49111. * @param system Define the `lensFlareSystem` this flare is part of
  49112. */
  49113. constructor(
  49114. /**
  49115. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49116. */
  49117. size: number,
  49118. /**
  49119. * 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.
  49120. */
  49121. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49122. /**
  49123. * Dispose and release the lens flare with its associated resources.
  49124. */
  49125. dispose(): void;
  49126. }
  49127. }
  49128. declare module BABYLON {
  49129. interface AbstractScene {
  49130. /**
  49131. * The list of lens flare system added to the scene
  49132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49133. */
  49134. lensFlareSystems: Array<LensFlareSystem>;
  49135. /**
  49136. * Removes the given lens flare system from this scene.
  49137. * @param toRemove The lens flare system to remove
  49138. * @returns The index of the removed lens flare system
  49139. */
  49140. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49141. /**
  49142. * Adds the given lens flare system to this scene
  49143. * @param newLensFlareSystem The lens flare system to add
  49144. */
  49145. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49146. /**
  49147. * Gets a lens flare system using its name
  49148. * @param name defines the name to look for
  49149. * @returns the lens flare system or null if not found
  49150. */
  49151. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49152. /**
  49153. * Gets a lens flare system using its id
  49154. * @param id defines the id to look for
  49155. * @returns the lens flare system or null if not found
  49156. */
  49157. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49158. }
  49159. /**
  49160. * Defines the lens flare scene component responsible to manage any lens flares
  49161. * in a given scene.
  49162. */
  49163. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49164. /**
  49165. * The component name helpfull to identify the component in the list of scene components.
  49166. */
  49167. readonly name: string;
  49168. /**
  49169. * The scene the component belongs to.
  49170. */
  49171. scene: Scene;
  49172. /**
  49173. * Creates a new instance of the component for the given scene
  49174. * @param scene Defines the scene to register the component in
  49175. */
  49176. constructor(scene: Scene);
  49177. /**
  49178. * Registers the component in a given scene
  49179. */
  49180. register(): void;
  49181. /**
  49182. * Rebuilds the elements related to this component in case of
  49183. * context lost for instance.
  49184. */
  49185. rebuild(): void;
  49186. /**
  49187. * Adds all the elements from the container to the scene
  49188. * @param container the container holding the elements
  49189. */
  49190. addFromContainer(container: AbstractScene): void;
  49191. /**
  49192. * Removes all the elements in the container from the scene
  49193. * @param container contains the elements to remove
  49194. * @param dispose if the removed element should be disposed (default: false)
  49195. */
  49196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49197. /**
  49198. * Serializes the component data to the specified json object
  49199. * @param serializationObject The object to serialize to
  49200. */
  49201. serialize(serializationObject: any): void;
  49202. /**
  49203. * Disposes the component and the associated ressources.
  49204. */
  49205. dispose(): void;
  49206. private _draw;
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * Defines the shadow generator component responsible to manage any shadow generators
  49212. * in a given scene.
  49213. */
  49214. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49215. /**
  49216. * The component name helpfull to identify the component in the list of scene components.
  49217. */
  49218. readonly name: string;
  49219. /**
  49220. * The scene the component belongs to.
  49221. */
  49222. scene: Scene;
  49223. /**
  49224. * Creates a new instance of the component for the given scene
  49225. * @param scene Defines the scene to register the component in
  49226. */
  49227. constructor(scene: Scene);
  49228. /**
  49229. * Registers the component in a given scene
  49230. */
  49231. register(): void;
  49232. /**
  49233. * Rebuilds the elements related to this component in case of
  49234. * context lost for instance.
  49235. */
  49236. rebuild(): void;
  49237. /**
  49238. * Serializes the component data to the specified json object
  49239. * @param serializationObject The object to serialize to
  49240. */
  49241. serialize(serializationObject: any): void;
  49242. /**
  49243. * Adds all the elements from the container to the scene
  49244. * @param container the container holding the elements
  49245. */
  49246. addFromContainer(container: AbstractScene): void;
  49247. /**
  49248. * Removes all the elements in the container from the scene
  49249. * @param container contains the elements to remove
  49250. * @param dispose if the removed element should be disposed (default: false)
  49251. */
  49252. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49253. /**
  49254. * Rebuilds the elements related to this component in case of
  49255. * context lost for instance.
  49256. */
  49257. dispose(): void;
  49258. private _gatherRenderTargets;
  49259. }
  49260. }
  49261. declare module BABYLON {
  49262. /**
  49263. * A point light is a light defined by an unique point in world space.
  49264. * The light is emitted in every direction from this point.
  49265. * A good example of a point light is a standard light bulb.
  49266. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49267. */
  49268. export class PointLight extends ShadowLight {
  49269. private _shadowAngle;
  49270. /**
  49271. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49272. * This specifies what angle the shadow will use to be created.
  49273. *
  49274. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49275. */
  49276. /**
  49277. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49278. * This specifies what angle the shadow will use to be created.
  49279. *
  49280. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49281. */
  49282. shadowAngle: number;
  49283. /**
  49284. * Gets the direction if it has been set.
  49285. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49286. */
  49287. /**
  49288. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49289. */
  49290. direction: Vector3;
  49291. /**
  49292. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49293. * A PointLight emits the light in every direction.
  49294. * It can cast shadows.
  49295. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49296. * ```javascript
  49297. * var pointLight = new PointLight("pl", camera.position, scene);
  49298. * ```
  49299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49300. * @param name The light friendly name
  49301. * @param position The position of the point light in the scene
  49302. * @param scene The scene the lights belongs to
  49303. */
  49304. constructor(name: string, position: Vector3, scene: Scene);
  49305. /**
  49306. * Returns the string "PointLight"
  49307. * @returns the class name
  49308. */
  49309. getClassName(): string;
  49310. /**
  49311. * Returns the integer 0.
  49312. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49313. */
  49314. getTypeID(): number;
  49315. /**
  49316. * Specifies wether or not the shadowmap should be a cube texture.
  49317. * @returns true if the shadowmap needs to be a cube texture.
  49318. */
  49319. needCube(): boolean;
  49320. /**
  49321. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49322. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49323. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49324. */
  49325. getShadowDirection(faceIndex?: number): Vector3;
  49326. /**
  49327. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49328. * - fov = PI / 2
  49329. * - aspect ratio : 1.0
  49330. * - z-near and far equal to the active camera minZ and maxZ.
  49331. * Returns the PointLight.
  49332. */
  49333. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49334. protected _buildUniformLayout(): void;
  49335. /**
  49336. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49337. * @param effect The effect to update
  49338. * @param lightIndex The index of the light in the effect to update
  49339. * @returns The point light
  49340. */
  49341. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49342. /**
  49343. * Prepares the list of defines specific to the light type.
  49344. * @param defines the list of defines
  49345. * @param lightIndex defines the index of the light for the effect
  49346. */
  49347. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * Header information of HDR texture files.
  49353. */
  49354. export interface HDRInfo {
  49355. /**
  49356. * The height of the texture in pixels.
  49357. */
  49358. height: number;
  49359. /**
  49360. * The width of the texture in pixels.
  49361. */
  49362. width: number;
  49363. /**
  49364. * The index of the beginning of the data in the binary file.
  49365. */
  49366. dataPosition: number;
  49367. }
  49368. /**
  49369. * This groups tools to convert HDR texture to native colors array.
  49370. */
  49371. export class HDRTools {
  49372. private static Ldexp;
  49373. private static Rgbe2float;
  49374. private static readStringLine;
  49375. /**
  49376. * Reads header information from an RGBE texture stored in a native array.
  49377. * More information on this format are available here:
  49378. * https://en.wikipedia.org/wiki/RGBE_image_format
  49379. *
  49380. * @param uint8array The binary file stored in native array.
  49381. * @return The header information.
  49382. */
  49383. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49384. /**
  49385. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49386. * This RGBE texture needs to store the information as a panorama.
  49387. *
  49388. * More information on this format are available here:
  49389. * https://en.wikipedia.org/wiki/RGBE_image_format
  49390. *
  49391. * @param buffer The binary file stored in an array buffer.
  49392. * @param size The expected size of the extracted cubemap.
  49393. * @return The Cube Map information.
  49394. */
  49395. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49396. /**
  49397. * Returns the pixels data extracted from an RGBE texture.
  49398. * This pixels will be stored left to right up to down in the R G B order in one array.
  49399. *
  49400. * More information on this format are available here:
  49401. * https://en.wikipedia.org/wiki/RGBE_image_format
  49402. *
  49403. * @param uint8array The binary file stored in an array buffer.
  49404. * @param hdrInfo The header information of the file.
  49405. * @return The pixels data in RGB right to left up to down order.
  49406. */
  49407. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49408. private static RGBE_ReadPixels_RLE;
  49409. }
  49410. }
  49411. declare module BABYLON {
  49412. /**
  49413. * This represents a texture coming from an HDR input.
  49414. *
  49415. * The only supported format is currently panorama picture stored in RGBE format.
  49416. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49417. */
  49418. export class HDRCubeTexture extends BaseTexture {
  49419. private static _facesMapping;
  49420. private _generateHarmonics;
  49421. private _noMipmap;
  49422. private _textureMatrix;
  49423. private _size;
  49424. private _onLoad;
  49425. private _onError;
  49426. /**
  49427. * The texture URL.
  49428. */
  49429. url: string;
  49430. /**
  49431. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49432. */
  49433. coordinatesMode: number;
  49434. protected _isBlocking: boolean;
  49435. /**
  49436. * Sets wether or not the texture is blocking during loading.
  49437. */
  49438. /**
  49439. * Gets wether or not the texture is blocking during loading.
  49440. */
  49441. isBlocking: boolean;
  49442. protected _rotationY: number;
  49443. /**
  49444. * Sets texture matrix rotation angle around Y axis in radians.
  49445. */
  49446. /**
  49447. * Gets texture matrix rotation angle around Y axis radians.
  49448. */
  49449. rotationY: number;
  49450. /**
  49451. * Gets or sets the center of the bounding box associated with the cube texture
  49452. * It must define where the camera used to render the texture was set
  49453. */
  49454. boundingBoxPosition: Vector3;
  49455. private _boundingBoxSize;
  49456. /**
  49457. * Gets or sets the size of the bounding box associated with the cube texture
  49458. * When defined, the cubemap will switch to local mode
  49459. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49460. * @example https://www.babylonjs-playground.com/#RNASML
  49461. */
  49462. boundingBoxSize: Vector3;
  49463. /**
  49464. * Instantiates an HDRTexture from the following parameters.
  49465. *
  49466. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49467. * @param scene The scene the texture will be used in
  49468. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49469. * @param noMipmap Forces to not generate the mipmap if true
  49470. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49471. * @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)
  49472. * @param reserved Reserved flag for internal use.
  49473. */
  49474. 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>);
  49475. /**
  49476. * Get the current class name of the texture useful for serialization or dynamic coding.
  49477. * @returns "HDRCubeTexture"
  49478. */
  49479. getClassName(): string;
  49480. /**
  49481. * Occurs when the file is raw .hdr file.
  49482. */
  49483. private loadTexture;
  49484. clone(): HDRCubeTexture;
  49485. delayLoad(): void;
  49486. /**
  49487. * Get the texture reflection matrix used to rotate/transform the reflection.
  49488. * @returns the reflection matrix
  49489. */
  49490. getReflectionTextureMatrix(): Matrix;
  49491. /**
  49492. * Set the texture reflection matrix used to rotate/transform the reflection.
  49493. * @param value Define the reflection matrix to set
  49494. */
  49495. setReflectionTextureMatrix(value: Matrix): void;
  49496. /**
  49497. * Parses a JSON representation of an HDR Texture in order to create the texture
  49498. * @param parsedTexture Define the JSON representation
  49499. * @param scene Define the scene the texture should be created in
  49500. * @param rootUrl Define the root url in case we need to load relative dependencies
  49501. * @returns the newly created texture after parsing
  49502. */
  49503. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49504. serialize(): any;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /**
  49509. * Class used to control physics engine
  49510. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49511. */
  49512. export class PhysicsEngine implements IPhysicsEngine {
  49513. private _physicsPlugin;
  49514. /**
  49515. * Global value used to control the smallest number supported by the simulation
  49516. */
  49517. static Epsilon: number;
  49518. private _impostors;
  49519. private _joints;
  49520. /**
  49521. * Gets the gravity vector used by the simulation
  49522. */
  49523. gravity: Vector3;
  49524. /**
  49525. * Factory used to create the default physics plugin.
  49526. * @returns The default physics plugin
  49527. */
  49528. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49529. /**
  49530. * Creates a new Physics Engine
  49531. * @param gravity defines the gravity vector used by the simulation
  49532. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49533. */
  49534. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49535. /**
  49536. * Sets the gravity vector used by the simulation
  49537. * @param gravity defines the gravity vector to use
  49538. */
  49539. setGravity(gravity: Vector3): void;
  49540. /**
  49541. * Set the time step of the physics engine.
  49542. * Default is 1/60.
  49543. * To slow it down, enter 1/600 for example.
  49544. * To speed it up, 1/30
  49545. * @param newTimeStep defines the new timestep to apply to this world.
  49546. */
  49547. setTimeStep(newTimeStep?: number): void;
  49548. /**
  49549. * Get the time step of the physics engine.
  49550. * @returns the current time step
  49551. */
  49552. getTimeStep(): number;
  49553. /**
  49554. * Release all resources
  49555. */
  49556. dispose(): void;
  49557. /**
  49558. * Gets the name of the current physics plugin
  49559. * @returns the name of the plugin
  49560. */
  49561. getPhysicsPluginName(): string;
  49562. /**
  49563. * Adding a new impostor for the impostor tracking.
  49564. * This will be done by the impostor itself.
  49565. * @param impostor the impostor to add
  49566. */
  49567. addImpostor(impostor: PhysicsImpostor): void;
  49568. /**
  49569. * Remove an impostor from the engine.
  49570. * This impostor and its mesh will not longer be updated by the physics engine.
  49571. * @param impostor the impostor to remove
  49572. */
  49573. removeImpostor(impostor: PhysicsImpostor): void;
  49574. /**
  49575. * Add a joint to the physics engine
  49576. * @param mainImpostor defines the main impostor to which the joint is added.
  49577. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49578. * @param joint defines the joint that will connect both impostors.
  49579. */
  49580. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49581. /**
  49582. * Removes a joint from the simulation
  49583. * @param mainImpostor defines the impostor used with the joint
  49584. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49585. * @param joint defines the joint to remove
  49586. */
  49587. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49588. /**
  49589. * Called by the scene. No need to call it.
  49590. * @param delta defines the timespam between frames
  49591. */
  49592. _step(delta: number): void;
  49593. /**
  49594. * Gets the current plugin used to run the simulation
  49595. * @returns current plugin
  49596. */
  49597. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49598. /**
  49599. * Gets the list of physic impostors
  49600. * @returns an array of PhysicsImpostor
  49601. */
  49602. getImpostors(): Array<PhysicsImpostor>;
  49603. /**
  49604. * Gets the impostor for a physics enabled object
  49605. * @param object defines the object impersonated by the impostor
  49606. * @returns the PhysicsImpostor or null if not found
  49607. */
  49608. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49609. /**
  49610. * Gets the impostor for a physics body object
  49611. * @param body defines physics body used by the impostor
  49612. * @returns the PhysicsImpostor or null if not found
  49613. */
  49614. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49615. /**
  49616. * Does a raycast in the physics world
  49617. * @param from when should the ray start?
  49618. * @param to when should the ray end?
  49619. * @returns PhysicsRaycastResult
  49620. */
  49621. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49622. }
  49623. }
  49624. declare module BABYLON {
  49625. /** @hidden */
  49626. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49627. private _useDeltaForWorldStep;
  49628. world: any;
  49629. name: string;
  49630. private _physicsMaterials;
  49631. private _fixedTimeStep;
  49632. private _cannonRaycastResult;
  49633. private _raycastResult;
  49634. private _physicsBodysToRemoveAfterStep;
  49635. BJSCANNON: any;
  49636. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49637. setGravity(gravity: Vector3): void;
  49638. setTimeStep(timeStep: number): void;
  49639. getTimeStep(): number;
  49640. executeStep(delta: number): void;
  49641. private _removeMarkedPhysicsBodiesFromWorld;
  49642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49645. private _processChildMeshes;
  49646. removePhysicsBody(impostor: PhysicsImpostor): void;
  49647. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49648. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49649. private _addMaterial;
  49650. private _checkWithEpsilon;
  49651. private _createShape;
  49652. private _createHeightmap;
  49653. private _minus90X;
  49654. private _plus90X;
  49655. private _tmpPosition;
  49656. private _tmpDeltaPosition;
  49657. private _tmpUnityRotation;
  49658. private _updatePhysicsBodyTransformation;
  49659. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49660. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49661. isSupported(): boolean;
  49662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49667. getBodyMass(impostor: PhysicsImpostor): number;
  49668. getBodyFriction(impostor: PhysicsImpostor): number;
  49669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49670. getBodyRestitution(impostor: PhysicsImpostor): number;
  49671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49672. sleepBody(impostor: PhysicsImpostor): void;
  49673. wakeUpBody(impostor: PhysicsImpostor): void;
  49674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49675. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49676. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49677. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49678. getRadius(impostor: PhysicsImpostor): number;
  49679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49680. dispose(): void;
  49681. private _extendNamespace;
  49682. /**
  49683. * Does a raycast in the physics world
  49684. * @param from when should the ray start?
  49685. * @param to when should the ray end?
  49686. * @returns PhysicsRaycastResult
  49687. */
  49688. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49689. }
  49690. }
  49691. declare module BABYLON {
  49692. /** @hidden */
  49693. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49694. world: any;
  49695. name: string;
  49696. BJSOIMO: any;
  49697. private _raycastResult;
  49698. constructor(iterations?: number, oimoInjection?: any);
  49699. setGravity(gravity: Vector3): void;
  49700. setTimeStep(timeStep: number): void;
  49701. getTimeStep(): number;
  49702. private _tmpImpostorsArray;
  49703. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49705. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49706. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49707. private _tmpPositionVector;
  49708. removePhysicsBody(impostor: PhysicsImpostor): void;
  49709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49710. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49711. isSupported(): boolean;
  49712. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49713. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49714. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49717. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49718. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49719. getBodyMass(impostor: PhysicsImpostor): number;
  49720. getBodyFriction(impostor: PhysicsImpostor): number;
  49721. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49722. getBodyRestitution(impostor: PhysicsImpostor): number;
  49723. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49724. sleepBody(impostor: PhysicsImpostor): void;
  49725. wakeUpBody(impostor: PhysicsImpostor): void;
  49726. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49727. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49728. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49729. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49730. getRadius(impostor: PhysicsImpostor): number;
  49731. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49732. dispose(): void;
  49733. /**
  49734. * Does a raycast in the physics world
  49735. * @param from when should the ray start?
  49736. * @param to when should the ray end?
  49737. * @returns PhysicsRaycastResult
  49738. */
  49739. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49740. }
  49741. }
  49742. declare module BABYLON {
  49743. /**
  49744. * Class containing static functions to help procedurally build meshes
  49745. */
  49746. export class RibbonBuilder {
  49747. /**
  49748. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49749. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49750. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49751. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49752. * * 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
  49753. * * 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
  49754. * * 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
  49755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49756. * * 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
  49757. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49758. * * 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
  49759. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49760. * * 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
  49761. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49763. * @param name defines the name of the mesh
  49764. * @param options defines the options used to create the mesh
  49765. * @param scene defines the hosting scene
  49766. * @returns the ribbon mesh
  49767. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49768. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49769. */
  49770. static CreateRibbon(name: string, options: {
  49771. pathArray: Vector3[][];
  49772. closeArray?: boolean;
  49773. closePath?: boolean;
  49774. offset?: number;
  49775. updatable?: boolean;
  49776. sideOrientation?: number;
  49777. frontUVs?: Vector4;
  49778. backUVs?: Vector4;
  49779. instance?: Mesh;
  49780. invertUV?: boolean;
  49781. uvs?: Vector2[];
  49782. colors?: Color4[];
  49783. }, scene?: Nullable<Scene>): Mesh;
  49784. }
  49785. }
  49786. declare module BABYLON {
  49787. /**
  49788. * Class containing static functions to help procedurally build meshes
  49789. */
  49790. export class ShapeBuilder {
  49791. /**
  49792. * 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.
  49793. * * 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.
  49794. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49795. * * 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.
  49796. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49797. * * 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
  49798. * * 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
  49799. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49801. * * 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
  49802. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49804. * @param name defines the name of the mesh
  49805. * @param options defines the options used to create the mesh
  49806. * @param scene defines the hosting scene
  49807. * @returns the extruded shape mesh
  49808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49810. */
  49811. static ExtrudeShape(name: string, options: {
  49812. shape: Vector3[];
  49813. path: Vector3[];
  49814. scale?: number;
  49815. rotation?: number;
  49816. cap?: number;
  49817. updatable?: boolean;
  49818. sideOrientation?: number;
  49819. frontUVs?: Vector4;
  49820. backUVs?: Vector4;
  49821. instance?: Mesh;
  49822. invertUV?: boolean;
  49823. }, scene?: Nullable<Scene>): Mesh;
  49824. /**
  49825. * Creates an custom extruded shape mesh.
  49826. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49827. * * 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.
  49828. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49829. * * 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
  49830. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49831. * * 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
  49832. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49833. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49834. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49835. * * 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
  49836. * * 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
  49837. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49839. * * 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
  49840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49842. * @param name defines the name of the mesh
  49843. * @param options defines the options used to create the mesh
  49844. * @param scene defines the hosting scene
  49845. * @returns the custom extruded shape mesh
  49846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49849. */
  49850. static ExtrudeShapeCustom(name: string, options: {
  49851. shape: Vector3[];
  49852. path: Vector3[];
  49853. scaleFunction?: any;
  49854. rotationFunction?: any;
  49855. ribbonCloseArray?: boolean;
  49856. ribbonClosePath?: boolean;
  49857. cap?: number;
  49858. updatable?: boolean;
  49859. sideOrientation?: number;
  49860. frontUVs?: Vector4;
  49861. backUVs?: Vector4;
  49862. instance?: Mesh;
  49863. invertUV?: boolean;
  49864. }, scene?: Nullable<Scene>): Mesh;
  49865. private static _ExtrudeShapeGeneric;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * AmmoJS Physics plugin
  49871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49872. * @see https://github.com/kripken/ammo.js/
  49873. */
  49874. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49875. private _useDeltaForWorldStep;
  49876. /**
  49877. * Reference to the Ammo library
  49878. */
  49879. bjsAMMO: any;
  49880. /**
  49881. * Created ammoJS world which physics bodies are added to
  49882. */
  49883. world: any;
  49884. /**
  49885. * Name of the plugin
  49886. */
  49887. name: string;
  49888. private _timeStep;
  49889. private _fixedTimeStep;
  49890. private _maxSteps;
  49891. private _tmpQuaternion;
  49892. private _tmpAmmoTransform;
  49893. private _tmpAmmoQuaternion;
  49894. private _tmpAmmoConcreteContactResultCallback;
  49895. private _collisionConfiguration;
  49896. private _dispatcher;
  49897. private _overlappingPairCache;
  49898. private _solver;
  49899. private _softBodySolver;
  49900. private _tmpAmmoVectorA;
  49901. private _tmpAmmoVectorB;
  49902. private _tmpAmmoVectorC;
  49903. private _tmpAmmoVectorD;
  49904. private _tmpContactCallbackResult;
  49905. private _tmpAmmoVectorRCA;
  49906. private _tmpAmmoVectorRCB;
  49907. private _raycastResult;
  49908. private static readonly DISABLE_COLLISION_FLAG;
  49909. private static readonly KINEMATIC_FLAG;
  49910. private static readonly DISABLE_DEACTIVATION_FLAG;
  49911. /**
  49912. * Initializes the ammoJS plugin
  49913. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49914. * @param ammoInjection can be used to inject your own ammo reference
  49915. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49916. */
  49917. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49918. /**
  49919. * Sets the gravity of the physics world (m/(s^2))
  49920. * @param gravity Gravity to set
  49921. */
  49922. setGravity(gravity: Vector3): void;
  49923. /**
  49924. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49925. * @param timeStep timestep to use in seconds
  49926. */
  49927. setTimeStep(timeStep: number): void;
  49928. /**
  49929. * 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)
  49930. * @param fixedTimeStep fixedTimeStep to use in seconds
  49931. */
  49932. setFixedTimeStep(fixedTimeStep: number): void;
  49933. /**
  49934. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49935. * @param maxSteps the maximum number of steps by the physics engine per frame
  49936. */
  49937. setMaxSteps(maxSteps: number): void;
  49938. /**
  49939. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49940. * @returns the current timestep in seconds
  49941. */
  49942. getTimeStep(): number;
  49943. private _isImpostorInContact;
  49944. private _isImpostorPairInContact;
  49945. private _stepSimulation;
  49946. /**
  49947. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49948. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49949. * After the step the babylon meshes are set to the position of the physics imposters
  49950. * @param delta amount of time to step forward
  49951. * @param impostors array of imposters to update before/after the step
  49952. */
  49953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49954. /**
  49955. * Update babylon mesh to match physics world object
  49956. * @param impostor imposter to match
  49957. */
  49958. private _afterSoftStep;
  49959. /**
  49960. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49961. * @param impostor imposter to match
  49962. */
  49963. private _ropeStep;
  49964. /**
  49965. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49966. * @param impostor imposter to match
  49967. */
  49968. private _softbodyOrClothStep;
  49969. private _tmpVector;
  49970. private _tmpMatrix;
  49971. /**
  49972. * Applies an impulse on the imposter
  49973. * @param impostor imposter to apply impulse to
  49974. * @param force amount of force to be applied to the imposter
  49975. * @param contactPoint the location to apply the impulse on the imposter
  49976. */
  49977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49978. /**
  49979. * Applies a force on the imposter
  49980. * @param impostor imposter to apply force
  49981. * @param force amount of force to be applied to the imposter
  49982. * @param contactPoint the location to apply the force on the imposter
  49983. */
  49984. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49985. /**
  49986. * Creates a physics body using the plugin
  49987. * @param impostor the imposter to create the physics body on
  49988. */
  49989. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49990. /**
  49991. * Removes the physics body from the imposter and disposes of the body's memory
  49992. * @param impostor imposter to remove the physics body from
  49993. */
  49994. removePhysicsBody(impostor: PhysicsImpostor): void;
  49995. /**
  49996. * Generates a joint
  49997. * @param impostorJoint the imposter joint to create the joint with
  49998. */
  49999. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50000. /**
  50001. * Removes a joint
  50002. * @param impostorJoint the imposter joint to remove the joint from
  50003. */
  50004. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50005. private _addMeshVerts;
  50006. /**
  50007. * Initialise the soft body vertices to match its object's (mesh) vertices
  50008. * Softbody vertices (nodes) are in world space and to match this
  50009. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50010. * @param impostor to create the softbody for
  50011. */
  50012. private _softVertexData;
  50013. /**
  50014. * Create an impostor's soft body
  50015. * @param impostor to create the softbody for
  50016. */
  50017. private _createSoftbody;
  50018. /**
  50019. * Create cloth for an impostor
  50020. * @param impostor to create the softbody for
  50021. */
  50022. private _createCloth;
  50023. /**
  50024. * Create rope for an impostor
  50025. * @param impostor to create the softbody for
  50026. */
  50027. private _createRope;
  50028. private _addHullVerts;
  50029. private _createShape;
  50030. /**
  50031. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50032. * @param impostor imposter containing the physics body and babylon object
  50033. */
  50034. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50035. /**
  50036. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50037. * @param impostor imposter containing the physics body and babylon object
  50038. * @param newPosition new position
  50039. * @param newRotation new rotation
  50040. */
  50041. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50042. /**
  50043. * If this plugin is supported
  50044. * @returns true if its supported
  50045. */
  50046. isSupported(): boolean;
  50047. /**
  50048. * Sets the linear velocity of the physics body
  50049. * @param impostor imposter to set the velocity on
  50050. * @param velocity velocity to set
  50051. */
  50052. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50053. /**
  50054. * Sets the angular velocity of the physics body
  50055. * @param impostor imposter to set the velocity on
  50056. * @param velocity velocity to set
  50057. */
  50058. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50059. /**
  50060. * gets the linear velocity
  50061. * @param impostor imposter to get linear velocity from
  50062. * @returns linear velocity
  50063. */
  50064. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50065. /**
  50066. * gets the angular velocity
  50067. * @param impostor imposter to get angular velocity from
  50068. * @returns angular velocity
  50069. */
  50070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50071. /**
  50072. * Sets the mass of physics body
  50073. * @param impostor imposter to set the mass on
  50074. * @param mass mass to set
  50075. */
  50076. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50077. /**
  50078. * Gets the mass of the physics body
  50079. * @param impostor imposter to get the mass from
  50080. * @returns mass
  50081. */
  50082. getBodyMass(impostor: PhysicsImpostor): number;
  50083. /**
  50084. * Gets friction of the impostor
  50085. * @param impostor impostor to get friction from
  50086. * @returns friction value
  50087. */
  50088. getBodyFriction(impostor: PhysicsImpostor): number;
  50089. /**
  50090. * Sets friction of the impostor
  50091. * @param impostor impostor to set friction on
  50092. * @param friction friction value
  50093. */
  50094. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50095. /**
  50096. * Gets restitution of the impostor
  50097. * @param impostor impostor to get restitution from
  50098. * @returns restitution value
  50099. */
  50100. getBodyRestitution(impostor: PhysicsImpostor): number;
  50101. /**
  50102. * Sets resitution of the impostor
  50103. * @param impostor impostor to set resitution on
  50104. * @param restitution resitution value
  50105. */
  50106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50107. /**
  50108. * Gets pressure inside the impostor
  50109. * @param impostor impostor to get pressure from
  50110. * @returns pressure value
  50111. */
  50112. getBodyPressure(impostor: PhysicsImpostor): number;
  50113. /**
  50114. * Sets pressure inside a soft body impostor
  50115. * Cloth and rope must remain 0 pressure
  50116. * @param impostor impostor to set pressure on
  50117. * @param pressure pressure value
  50118. */
  50119. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50120. /**
  50121. * Gets stiffness of the impostor
  50122. * @param impostor impostor to get stiffness from
  50123. * @returns pressure value
  50124. */
  50125. getBodyStiffness(impostor: PhysicsImpostor): number;
  50126. /**
  50127. * Sets stiffness of the impostor
  50128. * @param impostor impostor to set stiffness on
  50129. * @param stiffness stiffness value from 0 to 1
  50130. */
  50131. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50132. /**
  50133. * Gets velocityIterations of the impostor
  50134. * @param impostor impostor to get velocity iterations from
  50135. * @returns velocityIterations value
  50136. */
  50137. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50138. /**
  50139. * Sets velocityIterations of the impostor
  50140. * @param impostor impostor to set velocity iterations on
  50141. * @param velocityIterations velocityIterations value
  50142. */
  50143. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50144. /**
  50145. * Gets positionIterations of the impostor
  50146. * @param impostor impostor to get position iterations from
  50147. * @returns positionIterations value
  50148. */
  50149. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50150. /**
  50151. * Sets positionIterations of the impostor
  50152. * @param impostor impostor to set position on
  50153. * @param positionIterations positionIterations value
  50154. */
  50155. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50156. /**
  50157. * Append an anchor to a cloth object
  50158. * @param impostor is the cloth impostor to add anchor to
  50159. * @param otherImpostor is the rigid impostor to anchor to
  50160. * @param width ratio across width from 0 to 1
  50161. * @param height ratio up height from 0 to 1
  50162. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50163. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50164. */
  50165. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50166. /**
  50167. * Append an hook to a rope object
  50168. * @param impostor is the rope impostor to add hook to
  50169. * @param otherImpostor is the rigid impostor to hook to
  50170. * @param length ratio along the rope from 0 to 1
  50171. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50172. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50173. */
  50174. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50175. /**
  50176. * Sleeps the physics body and stops it from being active
  50177. * @param impostor impostor to sleep
  50178. */
  50179. sleepBody(impostor: PhysicsImpostor): void;
  50180. /**
  50181. * Activates the physics body
  50182. * @param impostor impostor to activate
  50183. */
  50184. wakeUpBody(impostor: PhysicsImpostor): void;
  50185. /**
  50186. * Updates the distance parameters of the joint
  50187. * @param joint joint to update
  50188. * @param maxDistance maximum distance of the joint
  50189. * @param minDistance minimum distance of the joint
  50190. */
  50191. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50192. /**
  50193. * Sets a motor on the joint
  50194. * @param joint joint to set motor on
  50195. * @param speed speed of the motor
  50196. * @param maxForce maximum force of the motor
  50197. * @param motorIndex index of the motor
  50198. */
  50199. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50200. /**
  50201. * Sets the motors limit
  50202. * @param joint joint to set limit on
  50203. * @param upperLimit upper limit
  50204. * @param lowerLimit lower limit
  50205. */
  50206. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50207. /**
  50208. * Syncs the position and rotation of a mesh with the impostor
  50209. * @param mesh mesh to sync
  50210. * @param impostor impostor to update the mesh with
  50211. */
  50212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50213. /**
  50214. * Gets the radius of the impostor
  50215. * @param impostor impostor to get radius from
  50216. * @returns the radius
  50217. */
  50218. getRadius(impostor: PhysicsImpostor): number;
  50219. /**
  50220. * Gets the box size of the impostor
  50221. * @param impostor impostor to get box size from
  50222. * @param result the resulting box size
  50223. */
  50224. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50225. /**
  50226. * Disposes of the impostor
  50227. */
  50228. dispose(): void;
  50229. /**
  50230. * Does a raycast in the physics world
  50231. * @param from when should the ray start?
  50232. * @param to when should the ray end?
  50233. * @returns PhysicsRaycastResult
  50234. */
  50235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50236. }
  50237. }
  50238. declare module BABYLON {
  50239. interface AbstractScene {
  50240. /**
  50241. * The list of reflection probes added to the scene
  50242. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50243. */
  50244. reflectionProbes: Array<ReflectionProbe>;
  50245. /**
  50246. * Removes the given reflection probe from this scene.
  50247. * @param toRemove The reflection probe to remove
  50248. * @returns The index of the removed reflection probe
  50249. */
  50250. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50251. /**
  50252. * Adds the given reflection probe to this scene.
  50253. * @param newReflectionProbe The reflection probe to add
  50254. */
  50255. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50256. }
  50257. /**
  50258. * Class used to generate realtime reflection / refraction cube textures
  50259. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50260. */
  50261. export class ReflectionProbe {
  50262. /** defines the name of the probe */
  50263. name: string;
  50264. private _scene;
  50265. private _renderTargetTexture;
  50266. private _projectionMatrix;
  50267. private _viewMatrix;
  50268. private _target;
  50269. private _add;
  50270. private _attachedMesh;
  50271. private _invertYAxis;
  50272. /** Gets or sets probe position (center of the cube map) */
  50273. position: Vector3;
  50274. /**
  50275. * Creates a new reflection probe
  50276. * @param name defines the name of the probe
  50277. * @param size defines the texture resolution (for each face)
  50278. * @param scene defines the hosting scene
  50279. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50280. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50281. */
  50282. constructor(
  50283. /** defines the name of the probe */
  50284. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50285. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50286. samples: number;
  50287. /** Gets or sets the refresh rate to use (on every frame by default) */
  50288. refreshRate: number;
  50289. /**
  50290. * Gets the hosting scene
  50291. * @returns a Scene
  50292. */
  50293. getScene(): Scene;
  50294. /** Gets the internal CubeTexture used to render to */
  50295. readonly cubeTexture: RenderTargetTexture;
  50296. /** Gets the list of meshes to render */
  50297. readonly renderList: Nullable<AbstractMesh[]>;
  50298. /**
  50299. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50300. * @param mesh defines the mesh to attach to
  50301. */
  50302. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50303. /**
  50304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50305. * @param renderingGroupId The rendering group id corresponding to its index
  50306. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50307. */
  50308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50309. /**
  50310. * Clean all associated resources
  50311. */
  50312. dispose(): void;
  50313. /**
  50314. * Converts the reflection probe information to a readable string for debug purpose.
  50315. * @param fullDetails Supports for multiple levels of logging within scene loading
  50316. * @returns the human readable reflection probe info
  50317. */
  50318. toString(fullDetails?: boolean): string;
  50319. /**
  50320. * Get the class name of the relfection probe.
  50321. * @returns "ReflectionProbe"
  50322. */
  50323. getClassName(): string;
  50324. /**
  50325. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50326. * @returns The JSON representation of the texture
  50327. */
  50328. serialize(): any;
  50329. /**
  50330. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50331. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50332. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50333. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50334. * @returns The parsed reflection probe if successful
  50335. */
  50336. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50337. }
  50338. }
  50339. declare module BABYLON {
  50340. /** @hidden */
  50341. export var _BabylonLoaderRegistered: boolean;
  50342. }
  50343. declare module BABYLON {
  50344. /**
  50345. * The Physically based simple base material of BJS.
  50346. *
  50347. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50348. * It is used as the base class for both the specGloss and metalRough conventions.
  50349. */
  50350. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50351. /**
  50352. * Number of Simultaneous lights allowed on the material.
  50353. */
  50354. maxSimultaneousLights: number;
  50355. /**
  50356. * If sets to true, disables all the lights affecting the material.
  50357. */
  50358. disableLighting: boolean;
  50359. /**
  50360. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50361. */
  50362. environmentTexture: BaseTexture;
  50363. /**
  50364. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50365. */
  50366. invertNormalMapX: boolean;
  50367. /**
  50368. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50369. */
  50370. invertNormalMapY: boolean;
  50371. /**
  50372. * Normal map used in the model.
  50373. */
  50374. normalTexture: BaseTexture;
  50375. /**
  50376. * Emissivie color used to self-illuminate the model.
  50377. */
  50378. emissiveColor: Color3;
  50379. /**
  50380. * Emissivie texture used to self-illuminate the model.
  50381. */
  50382. emissiveTexture: BaseTexture;
  50383. /**
  50384. * Occlusion Channel Strenght.
  50385. */
  50386. occlusionStrength: number;
  50387. /**
  50388. * Occlusion Texture of the material (adding extra occlusion effects).
  50389. */
  50390. occlusionTexture: BaseTexture;
  50391. /**
  50392. * Defines the alpha limits in alpha test mode.
  50393. */
  50394. alphaCutOff: number;
  50395. /**
  50396. * Gets the current double sided mode.
  50397. */
  50398. /**
  50399. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50400. */
  50401. doubleSided: boolean;
  50402. /**
  50403. * Stores the pre-calculated light information of a mesh in a texture.
  50404. */
  50405. lightmapTexture: BaseTexture;
  50406. /**
  50407. * If true, the light map contains occlusion information instead of lighting info.
  50408. */
  50409. useLightmapAsShadowmap: boolean;
  50410. /**
  50411. * Instantiates a new PBRMaterial instance.
  50412. *
  50413. * @param name The material name
  50414. * @param scene The scene the material will be use in.
  50415. */
  50416. constructor(name: string, scene: Scene);
  50417. getClassName(): string;
  50418. }
  50419. }
  50420. declare module BABYLON {
  50421. /**
  50422. * The PBR material of BJS following the metal roughness convention.
  50423. *
  50424. * This fits to the PBR convention in the GLTF definition:
  50425. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50426. */
  50427. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50428. /**
  50429. * The base color has two different interpretations depending on the value of metalness.
  50430. * When the material is a metal, the base color is the specific measured reflectance value
  50431. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50432. * of the material.
  50433. */
  50434. baseColor: Color3;
  50435. /**
  50436. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50437. * well as opacity information in the alpha channel.
  50438. */
  50439. baseTexture: BaseTexture;
  50440. /**
  50441. * Specifies the metallic scalar value of the material.
  50442. * Can also be used to scale the metalness values of the metallic texture.
  50443. */
  50444. metallic: number;
  50445. /**
  50446. * Specifies the roughness scalar value of the material.
  50447. * Can also be used to scale the roughness values of the metallic texture.
  50448. */
  50449. roughness: number;
  50450. /**
  50451. * Texture containing both the metallic value in the B channel and the
  50452. * roughness value in the G channel to keep better precision.
  50453. */
  50454. metallicRoughnessTexture: BaseTexture;
  50455. /**
  50456. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50457. *
  50458. * @param name The material name
  50459. * @param scene The scene the material will be use in.
  50460. */
  50461. constructor(name: string, scene: Scene);
  50462. /**
  50463. * Return the currrent class name of the material.
  50464. */
  50465. getClassName(): string;
  50466. /**
  50467. * Makes a duplicate of the current material.
  50468. * @param name - name to use for the new material.
  50469. */
  50470. clone(name: string): PBRMetallicRoughnessMaterial;
  50471. /**
  50472. * Serialize the material to a parsable JSON object.
  50473. */
  50474. serialize(): any;
  50475. /**
  50476. * Parses a JSON object correponding to the serialize function.
  50477. */
  50478. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50479. }
  50480. }
  50481. declare module BABYLON {
  50482. /**
  50483. * The PBR material of BJS following the specular glossiness convention.
  50484. *
  50485. * This fits to the PBR convention in the GLTF definition:
  50486. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50487. */
  50488. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50489. /**
  50490. * Specifies the diffuse color of the material.
  50491. */
  50492. diffuseColor: Color3;
  50493. /**
  50494. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50495. * channel.
  50496. */
  50497. diffuseTexture: BaseTexture;
  50498. /**
  50499. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50500. */
  50501. specularColor: Color3;
  50502. /**
  50503. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50504. */
  50505. glossiness: number;
  50506. /**
  50507. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50508. */
  50509. specularGlossinessTexture: BaseTexture;
  50510. /**
  50511. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50512. *
  50513. * @param name The material name
  50514. * @param scene The scene the material will be use in.
  50515. */
  50516. constructor(name: string, scene: Scene);
  50517. /**
  50518. * Return the currrent class name of the material.
  50519. */
  50520. getClassName(): string;
  50521. /**
  50522. * Makes a duplicate of the current material.
  50523. * @param name - name to use for the new material.
  50524. */
  50525. clone(name: string): PBRSpecularGlossinessMaterial;
  50526. /**
  50527. * Serialize the material to a parsable JSON object.
  50528. */
  50529. serialize(): any;
  50530. /**
  50531. * Parses a JSON object correponding to the serialize function.
  50532. */
  50533. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50534. }
  50535. }
  50536. declare module BABYLON {
  50537. /**
  50538. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50539. * It can help converting any input color in a desired output one. This can then be used to create effects
  50540. * from sepia, black and white to sixties or futuristic rendering...
  50541. *
  50542. * The only supported format is currently 3dl.
  50543. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50544. */
  50545. export class ColorGradingTexture extends BaseTexture {
  50546. /**
  50547. * The current texture matrix. (will always be identity in color grading texture)
  50548. */
  50549. private _textureMatrix;
  50550. /**
  50551. * The texture URL.
  50552. */
  50553. url: string;
  50554. /**
  50555. * Empty line regex stored for GC.
  50556. */
  50557. private static _noneEmptyLineRegex;
  50558. private _engine;
  50559. /**
  50560. * Instantiates a ColorGradingTexture from the following parameters.
  50561. *
  50562. * @param url The location of the color gradind data (currently only supporting 3dl)
  50563. * @param scene The scene the texture will be used in
  50564. */
  50565. constructor(url: string, scene: Scene);
  50566. /**
  50567. * Returns the texture matrix used in most of the material.
  50568. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50569. */
  50570. getTextureMatrix(): Matrix;
  50571. /**
  50572. * Occurs when the file being loaded is a .3dl LUT file.
  50573. */
  50574. private load3dlTexture;
  50575. /**
  50576. * Starts the loading process of the texture.
  50577. */
  50578. private loadTexture;
  50579. /**
  50580. * Clones the color gradind texture.
  50581. */
  50582. clone(): ColorGradingTexture;
  50583. /**
  50584. * Called during delayed load for textures.
  50585. */
  50586. delayLoad(): void;
  50587. /**
  50588. * Parses a color grading texture serialized by Babylon.
  50589. * @param parsedTexture The texture information being parsedTexture
  50590. * @param scene The scene to load the texture in
  50591. * @param rootUrl The root url of the data assets to load
  50592. * @return A color gradind texture
  50593. */
  50594. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50595. /**
  50596. * Serializes the LUT texture to json format.
  50597. */
  50598. serialize(): any;
  50599. }
  50600. }
  50601. declare module BABYLON {
  50602. /**
  50603. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50604. */
  50605. export class EquiRectangularCubeTexture extends BaseTexture {
  50606. /** The six faces of the cube. */
  50607. private static _FacesMapping;
  50608. private _noMipmap;
  50609. private _onLoad;
  50610. private _onError;
  50611. /** The size of the cubemap. */
  50612. private _size;
  50613. /** The buffer of the image. */
  50614. private _buffer;
  50615. /** The width of the input image. */
  50616. private _width;
  50617. /** The height of the input image. */
  50618. private _height;
  50619. /** The URL to the image. */
  50620. url: string;
  50621. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50622. coordinatesMode: number;
  50623. /**
  50624. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50625. * @param url The location of the image
  50626. * @param scene The scene the texture will be used in
  50627. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50628. * @param noMipmap Forces to not generate the mipmap if true
  50629. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50630. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50631. * @param onLoad — defines a callback called when texture is loaded
  50632. * @param onError — defines a callback called if there is an error
  50633. */
  50634. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50635. /**
  50636. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50637. */
  50638. private loadImage;
  50639. /**
  50640. * Convert the image buffer into a cubemap and create a CubeTexture.
  50641. */
  50642. private loadTexture;
  50643. /**
  50644. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50645. * @param buffer The ArrayBuffer that should be converted.
  50646. * @returns The buffer as Float32Array.
  50647. */
  50648. private getFloat32ArrayFromArrayBuffer;
  50649. /**
  50650. * Get the current class name of the texture useful for serialization or dynamic coding.
  50651. * @returns "EquiRectangularCubeTexture"
  50652. */
  50653. getClassName(): string;
  50654. /**
  50655. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50656. * @returns A clone of the current EquiRectangularCubeTexture.
  50657. */
  50658. clone(): EquiRectangularCubeTexture;
  50659. }
  50660. }
  50661. declare module BABYLON {
  50662. /**
  50663. * Based on jsTGALoader - Javascript loader for TGA file
  50664. * By Vincent Thibault
  50665. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50666. */
  50667. export class TGATools {
  50668. private static _TYPE_INDEXED;
  50669. private static _TYPE_RGB;
  50670. private static _TYPE_GREY;
  50671. private static _TYPE_RLE_INDEXED;
  50672. private static _TYPE_RLE_RGB;
  50673. private static _TYPE_RLE_GREY;
  50674. private static _ORIGIN_MASK;
  50675. private static _ORIGIN_SHIFT;
  50676. private static _ORIGIN_BL;
  50677. private static _ORIGIN_BR;
  50678. private static _ORIGIN_UL;
  50679. private static _ORIGIN_UR;
  50680. /**
  50681. * Gets the header of a TGA file
  50682. * @param data defines the TGA data
  50683. * @returns the header
  50684. */
  50685. static GetTGAHeader(data: Uint8Array): any;
  50686. /**
  50687. * Uploads TGA content to a Babylon Texture
  50688. * @hidden
  50689. */
  50690. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50691. /** @hidden */
  50692. 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;
  50693. /** @hidden */
  50694. 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;
  50695. /** @hidden */
  50696. 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;
  50697. /** @hidden */
  50698. 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;
  50699. /** @hidden */
  50700. 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;
  50701. /** @hidden */
  50702. 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;
  50703. }
  50704. }
  50705. declare module BABYLON {
  50706. /**
  50707. * Implementation of the TGA Texture Loader.
  50708. * @hidden
  50709. */
  50710. export class _TGATextureLoader implements IInternalTextureLoader {
  50711. /**
  50712. * Defines wether the loader supports cascade loading the different faces.
  50713. */
  50714. readonly supportCascades: boolean;
  50715. /**
  50716. * This returns if the loader support the current file information.
  50717. * @param extension defines the file extension of the file being loaded
  50718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50719. * @param fallback defines the fallback internal texture if any
  50720. * @param isBase64 defines whether the texture is encoded as a base64
  50721. * @param isBuffer defines whether the texture data are stored as a buffer
  50722. * @returns true if the loader can load the specified file
  50723. */
  50724. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50725. /**
  50726. * Transform the url before loading if required.
  50727. * @param rootUrl the url of the texture
  50728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50729. * @returns the transformed texture
  50730. */
  50731. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50732. /**
  50733. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50734. * @param rootUrl the url of the texture
  50735. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50736. * @returns the fallback texture
  50737. */
  50738. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50739. /**
  50740. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50741. * @param data contains the texture data
  50742. * @param texture defines the BabylonJS internal texture
  50743. * @param createPolynomials will be true if polynomials have been requested
  50744. * @param onLoad defines the callback to trigger once the texture is ready
  50745. * @param onError defines the callback to trigger in case of error
  50746. */
  50747. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50748. /**
  50749. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50750. * @param data contains the texture data
  50751. * @param texture defines the BabylonJS internal texture
  50752. * @param callback defines the method to call once ready to upload
  50753. */
  50754. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50755. }
  50756. }
  50757. declare module BABYLON {
  50758. /**
  50759. * Info about the .basis files
  50760. */
  50761. class BasisFileInfo {
  50762. /**
  50763. * If the file has alpha
  50764. */
  50765. hasAlpha: boolean;
  50766. /**
  50767. * Info about each image of the basis file
  50768. */
  50769. images: Array<{
  50770. levels: Array<{
  50771. width: number;
  50772. height: number;
  50773. transcodedPixels: ArrayBufferView;
  50774. }>;
  50775. }>;
  50776. }
  50777. /**
  50778. * Result of transcoding a basis file
  50779. */
  50780. class TranscodeResult {
  50781. /**
  50782. * Info about the .basis file
  50783. */
  50784. fileInfo: BasisFileInfo;
  50785. /**
  50786. * Format to use when loading the file
  50787. */
  50788. format: number;
  50789. }
  50790. /**
  50791. * Configuration options for the Basis transcoder
  50792. */
  50793. export class BasisTranscodeConfiguration {
  50794. /**
  50795. * Supported compression formats used to determine the supported output format of the transcoder
  50796. */
  50797. supportedCompressionFormats?: {
  50798. /**
  50799. * etc1 compression format
  50800. */
  50801. etc1?: boolean;
  50802. /**
  50803. * s3tc compression format
  50804. */
  50805. s3tc?: boolean;
  50806. /**
  50807. * pvrtc compression format
  50808. */
  50809. pvrtc?: boolean;
  50810. /**
  50811. * etc2 compression format
  50812. */
  50813. etc2?: boolean;
  50814. };
  50815. /**
  50816. * If mipmap levels should be loaded for transcoded images (Default: true)
  50817. */
  50818. loadMipmapLevels?: boolean;
  50819. /**
  50820. * Index of a single image to load (Default: all images)
  50821. */
  50822. loadSingleImage?: number;
  50823. }
  50824. /**
  50825. * Used to load .Basis files
  50826. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50827. */
  50828. export class BasisTools {
  50829. private static _IgnoreSupportedFormats;
  50830. /**
  50831. * URL to use when loading the basis transcoder
  50832. */
  50833. static JSModuleURL: string;
  50834. /**
  50835. * URL to use when loading the wasm module for the transcoder
  50836. */
  50837. static WasmModuleURL: string;
  50838. /**
  50839. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50840. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50841. * @returns internal format corresponding to the Basis format
  50842. */
  50843. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50844. private static _WorkerPromise;
  50845. private static _Worker;
  50846. private static _actionId;
  50847. private static _CreateWorkerAsync;
  50848. /**
  50849. * Transcodes a loaded image file to compressed pixel data
  50850. * @param imageData image data to transcode
  50851. * @param config configuration options for the transcoding
  50852. * @returns a promise resulting in the transcoded image
  50853. */
  50854. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50855. /**
  50856. * Loads a texture from the transcode result
  50857. * @param texture texture load to
  50858. * @param transcodeResult the result of transcoding the basis file to load from
  50859. */
  50860. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50861. }
  50862. }
  50863. declare module BABYLON {
  50864. /**
  50865. * Loader for .basis file format
  50866. */
  50867. export class _BasisTextureLoader implements IInternalTextureLoader {
  50868. /**
  50869. * Defines whether the loader supports cascade loading the different faces.
  50870. */
  50871. readonly supportCascades: boolean;
  50872. /**
  50873. * This returns if the loader support the current file information.
  50874. * @param extension defines the file extension of the file being loaded
  50875. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50876. * @param fallback defines the fallback internal texture if any
  50877. * @param isBase64 defines whether the texture is encoded as a base64
  50878. * @param isBuffer defines whether the texture data are stored as a buffer
  50879. * @returns true if the loader can load the specified file
  50880. */
  50881. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50882. /**
  50883. * Transform the url before loading if required.
  50884. * @param rootUrl the url of the texture
  50885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50886. * @returns the transformed texture
  50887. */
  50888. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50889. /**
  50890. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50891. * @param rootUrl the url of the texture
  50892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50893. * @returns the fallback texture
  50894. */
  50895. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50896. /**
  50897. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50898. * @param data contains the texture data
  50899. * @param texture defines the BabylonJS internal texture
  50900. * @param createPolynomials will be true if polynomials have been requested
  50901. * @param onLoad defines the callback to trigger once the texture is ready
  50902. * @param onError defines the callback to trigger in case of error
  50903. */
  50904. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50905. /**
  50906. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50907. * @param data contains the texture data
  50908. * @param texture defines the BabylonJS internal texture
  50909. * @param callback defines the method to call once ready to upload
  50910. */
  50911. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50912. }
  50913. }
  50914. declare module BABYLON {
  50915. /**
  50916. * 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.
  50917. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50919. */
  50920. export class CustomProceduralTexture extends ProceduralTexture {
  50921. private _animate;
  50922. private _time;
  50923. private _config;
  50924. private _texturePath;
  50925. /**
  50926. * Instantiates a new Custom Procedural Texture.
  50927. * 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.
  50928. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50929. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50930. * @param name Define the name of the texture
  50931. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50932. * @param size Define the size of the texture to create
  50933. * @param scene Define the scene the texture belongs to
  50934. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50935. * @param generateMipMaps Define if the texture should creates mip maps or not
  50936. */
  50937. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50938. private _loadJson;
  50939. /**
  50940. * Is the texture ready to be used ? (rendered at least once)
  50941. * @returns true if ready, otherwise, false.
  50942. */
  50943. isReady(): boolean;
  50944. /**
  50945. * Render the texture to its associated render target.
  50946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50947. */
  50948. render(useCameraPostProcess?: boolean): void;
  50949. /**
  50950. * Update the list of dependant textures samplers in the shader.
  50951. */
  50952. updateTextures(): void;
  50953. /**
  50954. * Update the uniform values of the procedural texture in the shader.
  50955. */
  50956. updateShaderUniforms(): void;
  50957. /**
  50958. * Define if the texture animates or not.
  50959. */
  50960. animate: boolean;
  50961. }
  50962. }
  50963. declare module BABYLON {
  50964. /** @hidden */
  50965. export var noisePixelShader: {
  50966. name: string;
  50967. shader: string;
  50968. };
  50969. }
  50970. declare module BABYLON {
  50971. /**
  50972. * Class used to generate noise procedural textures
  50973. */
  50974. export class NoiseProceduralTexture extends ProceduralTexture {
  50975. private _time;
  50976. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50977. brightness: number;
  50978. /** Defines the number of octaves to process */
  50979. octaves: number;
  50980. /** Defines the level of persistence (0.8 by default) */
  50981. persistence: number;
  50982. /** Gets or sets animation speed factor (default is 1) */
  50983. animationSpeedFactor: number;
  50984. /**
  50985. * Creates a new NoiseProceduralTexture
  50986. * @param name defines the name fo the texture
  50987. * @param size defines the size of the texture (default is 256)
  50988. * @param scene defines the hosting scene
  50989. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50990. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50991. */
  50992. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50993. private _updateShaderUniforms;
  50994. protected _getDefines(): string;
  50995. /** Generate the current state of the procedural texture */
  50996. render(useCameraPostProcess?: boolean): void;
  50997. /**
  50998. * Serializes this noise procedural texture
  50999. * @returns a serialized noise procedural texture object
  51000. */
  51001. serialize(): any;
  51002. /**
  51003. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51004. * @param parsedTexture defines parsed texture data
  51005. * @param scene defines the current scene
  51006. * @param rootUrl defines the root URL containing noise procedural texture information
  51007. * @returns a parsed NoiseProceduralTexture
  51008. */
  51009. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51010. }
  51011. }
  51012. declare module BABYLON {
  51013. /**
  51014. * Raw cube texture where the raw buffers are passed in
  51015. */
  51016. export class RawCubeTexture extends CubeTexture {
  51017. /**
  51018. * Creates a cube texture where the raw buffers are passed in.
  51019. * @param scene defines the scene the texture is attached to
  51020. * @param data defines the array of data to use to create each face
  51021. * @param size defines the size of the textures
  51022. * @param format defines the format of the data
  51023. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51024. * @param generateMipMaps defines if the engine should generate the mip levels
  51025. * @param invertY defines if data must be stored with Y axis inverted
  51026. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51027. * @param compression defines the compression used (null by default)
  51028. */
  51029. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51030. /**
  51031. * Updates the raw cube texture.
  51032. * @param data defines the data to store
  51033. * @param format defines the data format
  51034. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51035. * @param invertY defines if data must be stored with Y axis inverted
  51036. * @param compression defines the compression used (null by default)
  51037. * @param level defines which level of the texture to update
  51038. */
  51039. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51040. /**
  51041. * Updates a raw cube texture with RGBD encoded data.
  51042. * @param data defines the array of data [mipmap][face] to use to create each face
  51043. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51044. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51045. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51046. * @returns a promsie that resolves when the operation is complete
  51047. */
  51048. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51049. /**
  51050. * Clones the raw cube texture.
  51051. * @return a new cube texture
  51052. */
  51053. clone(): CubeTexture;
  51054. /** @hidden */
  51055. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Class used to store 3D textures containing user data
  51061. */
  51062. export class RawTexture3D extends Texture {
  51063. /** Gets or sets the texture format to use */
  51064. format: number;
  51065. private _engine;
  51066. /**
  51067. * Create a new RawTexture3D
  51068. * @param data defines the data of the texture
  51069. * @param width defines the width of the texture
  51070. * @param height defines the height of the texture
  51071. * @param depth defines the depth of the texture
  51072. * @param format defines the texture format to use
  51073. * @param scene defines the hosting scene
  51074. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51075. * @param invertY defines if texture must be stored with Y axis inverted
  51076. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51077. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51078. */
  51079. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51080. /** Gets or sets the texture format to use */
  51081. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51082. /**
  51083. * Update the texture with new data
  51084. * @param data defines the data to store in the texture
  51085. */
  51086. update(data: ArrayBufferView): void;
  51087. }
  51088. }
  51089. declare module BABYLON {
  51090. /**
  51091. * Creates a refraction texture used by refraction channel of the standard material.
  51092. * It is like a mirror but to see through a material.
  51093. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51094. */
  51095. export class RefractionTexture extends RenderTargetTexture {
  51096. /**
  51097. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51098. * 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.
  51099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51100. */
  51101. refractionPlane: Plane;
  51102. /**
  51103. * Define how deep under the surface we should see.
  51104. */
  51105. depth: number;
  51106. /**
  51107. * Creates a refraction texture used by refraction channel of the standard material.
  51108. * It is like a mirror but to see through a material.
  51109. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51110. * @param name Define the texture name
  51111. * @param size Define the size of the underlying texture
  51112. * @param scene Define the scene the refraction belongs to
  51113. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51114. */
  51115. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51116. /**
  51117. * Clone the refraction texture.
  51118. * @returns the cloned texture
  51119. */
  51120. clone(): RefractionTexture;
  51121. /**
  51122. * Serialize the texture to a JSON representation you could use in Parse later on
  51123. * @returns the serialized JSON representation
  51124. */
  51125. serialize(): any;
  51126. }
  51127. }
  51128. declare module BABYLON {
  51129. /**
  51130. * Defines the options related to the creation of an HtmlElementTexture
  51131. */
  51132. export interface IHtmlElementTextureOptions {
  51133. /**
  51134. * Defines wether mip maps should be created or not.
  51135. */
  51136. generateMipMaps?: boolean;
  51137. /**
  51138. * Defines the sampling mode of the texture.
  51139. */
  51140. samplingMode?: number;
  51141. /**
  51142. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51143. */
  51144. engine: Nullable<Engine>;
  51145. /**
  51146. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51147. */
  51148. scene: Nullable<Scene>;
  51149. }
  51150. /**
  51151. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51152. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51153. * is automatically managed.
  51154. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51155. * in your application.
  51156. *
  51157. * As the update is not automatic, you need to call them manually.
  51158. */
  51159. export class HtmlElementTexture extends BaseTexture {
  51160. /**
  51161. * The texture URL.
  51162. */
  51163. element: HTMLVideoElement | HTMLCanvasElement;
  51164. private static readonly DefaultOptions;
  51165. private _textureMatrix;
  51166. private _engine;
  51167. private _isVideo;
  51168. private _generateMipMaps;
  51169. private _samplingMode;
  51170. /**
  51171. * Instantiates a HtmlElementTexture from the following parameters.
  51172. *
  51173. * @param name Defines the name of the texture
  51174. * @param element Defines the video or canvas the texture is filled with
  51175. * @param options Defines the other none mandatory texture creation options
  51176. */
  51177. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51178. private _createInternalTexture;
  51179. /**
  51180. * Returns the texture matrix used in most of the material.
  51181. */
  51182. getTextureMatrix(): Matrix;
  51183. /**
  51184. * Updates the content of the texture.
  51185. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51186. */
  51187. update(invertY?: Nullable<boolean>): void;
  51188. }
  51189. }
  51190. declare module BABYLON {
  51191. /**
  51192. * Enum used to define the target of a block
  51193. */
  51194. export enum NodeMaterialBlockTargets {
  51195. /** Vertex shader */
  51196. Vertex = 1,
  51197. /** Fragment shader */
  51198. Fragment = 2,
  51199. /** Neutral */
  51200. Neutral = 4,
  51201. /** Vertex and Fragment */
  51202. VertexAndFragment = 3
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. /**
  51207. * Defines the kind of connection point for node based material
  51208. */
  51209. export enum NodeMaterialBlockConnectionPointTypes {
  51210. /** Float */
  51211. Float = 1,
  51212. /** Int */
  51213. Int = 2,
  51214. /** Vector2 */
  51215. Vector2 = 4,
  51216. /** Vector3 */
  51217. Vector3 = 8,
  51218. /** Vector4 */
  51219. Vector4 = 16,
  51220. /** Color3 */
  51221. Color3 = 32,
  51222. /** Color4 */
  51223. Color4 = 64,
  51224. /** Matrix */
  51225. Matrix = 128,
  51226. /** Detect type based on connection */
  51227. AutoDetect = 1024,
  51228. /** Output type that will be defined by input type */
  51229. BasedOnInput = 2048
  51230. }
  51231. }
  51232. declare module BABYLON {
  51233. /**
  51234. * Root class for all node material optimizers
  51235. */
  51236. export class NodeMaterialOptimizer {
  51237. /**
  51238. * Function used to optimize a NodeMaterial graph
  51239. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51240. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51241. */
  51242. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51243. }
  51244. }
  51245. declare module BABYLON {
  51246. /**
  51247. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51248. */
  51249. export class TransformBlock extends NodeMaterialBlock {
  51250. /**
  51251. * Defines the value to use to complement W value to transform it to a Vector4
  51252. */
  51253. complementW: number;
  51254. /**
  51255. * Defines the value to use to complement z value to transform it to a Vector4
  51256. */
  51257. complementZ: number;
  51258. /**
  51259. * Creates a new TransformBlock
  51260. * @param name defines the block name
  51261. */
  51262. constructor(name: string);
  51263. /**
  51264. * Gets the current class name
  51265. * @returns the class name
  51266. */
  51267. getClassName(): string;
  51268. /**
  51269. * Gets the vector input
  51270. */
  51271. readonly vector: NodeMaterialConnectionPoint;
  51272. /**
  51273. * Gets the output component
  51274. */
  51275. readonly output: NodeMaterialConnectionPoint;
  51276. /**
  51277. * Gets the matrix transform input
  51278. */
  51279. readonly transform: NodeMaterialConnectionPoint;
  51280. protected _buildBlock(state: NodeMaterialBuildState): this;
  51281. serialize(): any;
  51282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51283. }
  51284. }
  51285. declare module BABYLON {
  51286. /**
  51287. * Block used to output the vertex position
  51288. */
  51289. export class VertexOutputBlock extends NodeMaterialBlock {
  51290. /**
  51291. * Creates a new VertexOutputBlock
  51292. * @param name defines the block name
  51293. */
  51294. constructor(name: string);
  51295. /**
  51296. * Gets the current class name
  51297. * @returns the class name
  51298. */
  51299. getClassName(): string;
  51300. /**
  51301. * Gets the vector input component
  51302. */
  51303. readonly vector: NodeMaterialConnectionPoint;
  51304. protected _buildBlock(state: NodeMaterialBuildState): this;
  51305. }
  51306. }
  51307. declare module BABYLON {
  51308. /**
  51309. * Block used to output the final color
  51310. */
  51311. export class FragmentOutputBlock extends NodeMaterialBlock {
  51312. /**
  51313. * Create a new FragmentOutputBlock
  51314. * @param name defines the block name
  51315. */
  51316. constructor(name: string);
  51317. /**
  51318. * Gets the current class name
  51319. * @returns the class name
  51320. */
  51321. getClassName(): string;
  51322. /**
  51323. * Gets the rgba input component
  51324. */
  51325. readonly rgba: NodeMaterialConnectionPoint;
  51326. /**
  51327. * Gets the rgb input component
  51328. */
  51329. readonly rgb: NodeMaterialConnectionPoint;
  51330. /**
  51331. * Gets the a input component
  51332. */
  51333. readonly a: NodeMaterialConnectionPoint;
  51334. protected _buildBlock(state: NodeMaterialBuildState): this;
  51335. }
  51336. }
  51337. declare module BABYLON {
  51338. /**
  51339. * Interface used to configure the node material editor
  51340. */
  51341. export interface INodeMaterialEditorOptions {
  51342. /** Define the URl to load node editor script */
  51343. editorURL?: string;
  51344. }
  51345. /** @hidden */
  51346. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51347. /** BONES */
  51348. NUM_BONE_INFLUENCERS: number;
  51349. BonesPerMesh: number;
  51350. BONETEXTURE: boolean;
  51351. /** MORPH TARGETS */
  51352. MORPHTARGETS: boolean;
  51353. MORPHTARGETS_NORMAL: boolean;
  51354. MORPHTARGETS_TANGENT: boolean;
  51355. MORPHTARGETS_UV: boolean;
  51356. NUM_MORPH_INFLUENCERS: number;
  51357. /** IMAGE PROCESSING */
  51358. IMAGEPROCESSING: boolean;
  51359. VIGNETTE: boolean;
  51360. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51361. VIGNETTEBLENDMODEOPAQUE: boolean;
  51362. TONEMAPPING: boolean;
  51363. TONEMAPPING_ACES: boolean;
  51364. CONTRAST: boolean;
  51365. EXPOSURE: boolean;
  51366. COLORCURVES: boolean;
  51367. COLORGRADING: boolean;
  51368. COLORGRADING3D: boolean;
  51369. SAMPLER3DGREENDEPTH: boolean;
  51370. SAMPLER3DBGRMAP: boolean;
  51371. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51372. constructor();
  51373. setValue(name: string, value: boolean): void;
  51374. }
  51375. /**
  51376. * Class used to configure NodeMaterial
  51377. */
  51378. export interface INodeMaterialOptions {
  51379. /**
  51380. * Defines if blocks should emit comments
  51381. */
  51382. emitComments: boolean;
  51383. }
  51384. /**
  51385. * Class used to create a node based material built by assembling shader blocks
  51386. */
  51387. export class NodeMaterial extends PushMaterial {
  51388. private _options;
  51389. private _vertexCompilationState;
  51390. private _fragmentCompilationState;
  51391. private _sharedData;
  51392. private _buildId;
  51393. private _buildWasSuccessful;
  51394. private _cachedWorldViewMatrix;
  51395. private _cachedWorldViewProjectionMatrix;
  51396. private _optimizers;
  51397. /** Define the URl to load node editor script */
  51398. static EditorURL: string;
  51399. private BJSNODEMATERIALEDITOR;
  51400. /** Get the inspector from bundle or global */
  51401. private _getGlobalNodeMaterialEditor;
  51402. /**
  51403. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51404. */
  51405. ignoreAlpha: boolean;
  51406. /**
  51407. * Defines the maximum number of lights that can be used in the material
  51408. */
  51409. maxSimultaneousLights: number;
  51410. /**
  51411. * Observable raised when the material is built
  51412. */
  51413. onBuildObservable: Observable<NodeMaterial>;
  51414. /**
  51415. * Gets or sets the root nodes of the material vertex shader
  51416. */
  51417. _vertexOutputNodes: NodeMaterialBlock[];
  51418. /**
  51419. * Gets or sets the root nodes of the material fragment (pixel) shader
  51420. */
  51421. _fragmentOutputNodes: NodeMaterialBlock[];
  51422. /** Gets or sets options to control the node material overall behavior */
  51423. options: INodeMaterialOptions;
  51424. /**
  51425. * Default configuration related to image processing available in the standard Material.
  51426. */
  51427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51428. /**
  51429. * Gets the image processing configuration used either in this material.
  51430. */
  51431. /**
  51432. * Sets the Default image processing configuration used either in the this material.
  51433. *
  51434. * If sets to null, the scene one is in use.
  51435. */
  51436. imageProcessingConfiguration: ImageProcessingConfiguration;
  51437. /**
  51438. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51439. */
  51440. attachedBlocks: NodeMaterialBlock[];
  51441. /**
  51442. * Create a new node based material
  51443. * @param name defines the material name
  51444. * @param scene defines the hosting scene
  51445. * @param options defines creation option
  51446. */
  51447. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51448. /**
  51449. * Gets the current class name of the material e.g. "NodeMaterial"
  51450. * @returns the class name
  51451. */
  51452. getClassName(): string;
  51453. /**
  51454. * Keep track of the image processing observer to allow dispose and replace.
  51455. */
  51456. private _imageProcessingObserver;
  51457. /**
  51458. * Attaches a new image processing configuration to the Standard Material.
  51459. * @param configuration
  51460. */
  51461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51462. /**
  51463. * Adds a new optimizer to the list of optimizers
  51464. * @param optimizer defines the optimizers to add
  51465. * @returns the current material
  51466. */
  51467. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51468. /**
  51469. * Remove an optimizer from the list of optimizers
  51470. * @param optimizer defines the optimizers to remove
  51471. * @returns the current material
  51472. */
  51473. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51474. /**
  51475. * Add a new block to the list of output nodes
  51476. * @param node defines the node to add
  51477. * @returns the current material
  51478. */
  51479. addOutputNode(node: NodeMaterialBlock): this;
  51480. /**
  51481. * Remove a block from the list of root nodes
  51482. * @param node defines the node to remove
  51483. * @returns the current material
  51484. */
  51485. removeOutputNode(node: NodeMaterialBlock): this;
  51486. private _addVertexOutputNode;
  51487. private _removeVertexOutputNode;
  51488. private _addFragmentOutputNode;
  51489. private _removeFragmentOutputNode;
  51490. /**
  51491. * Specifies if the material will require alpha blending
  51492. * @returns a boolean specifying if alpha blending is needed
  51493. */
  51494. needAlphaBlending(): boolean;
  51495. /**
  51496. * Specifies if this material should be rendered in alpha test mode
  51497. * @returns a boolean specifying if an alpha test is needed.
  51498. */
  51499. needAlphaTesting(): boolean;
  51500. private _initializeBlock;
  51501. private _resetDualBlocks;
  51502. /**
  51503. * Build the material and generates the inner effect
  51504. * @param verbose defines if the build should log activity
  51505. */
  51506. build(verbose?: boolean): void;
  51507. /**
  51508. * Runs an otpimization phase to try to improve the shader code
  51509. */
  51510. optimize(): void;
  51511. private _prepareDefinesForAttributes;
  51512. /**
  51513. * Get if the submesh is ready to be used and all its information available.
  51514. * Child classes can use it to update shaders
  51515. * @param mesh defines the mesh to check
  51516. * @param subMesh defines which submesh to check
  51517. * @param useInstances specifies that instances should be used
  51518. * @returns a boolean indicating that the submesh is ready or not
  51519. */
  51520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51521. /**
  51522. * Get a string representing the shaders built by the current node graph
  51523. */
  51524. readonly compiledShaders: string;
  51525. /**
  51526. * Binds the world matrix to the material
  51527. * @param world defines the world transformation matrix
  51528. */
  51529. bindOnlyWorldMatrix(world: Matrix): void;
  51530. /**
  51531. * Binds the submesh to this material by preparing the effect and shader to draw
  51532. * @param world defines the world transformation matrix
  51533. * @param mesh defines the mesh containing the submesh
  51534. * @param subMesh defines the submesh to bind the material to
  51535. */
  51536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51537. /**
  51538. * Gets the active textures from the material
  51539. * @returns an array of textures
  51540. */
  51541. getActiveTextures(): BaseTexture[];
  51542. /**
  51543. * Specifies if the material uses a texture
  51544. * @param texture defines the texture to check against the material
  51545. * @returns a boolean specifying if the material uses the texture
  51546. */
  51547. hasTexture(texture: BaseTexture): boolean;
  51548. /**
  51549. * Disposes the material
  51550. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51551. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51552. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51553. */
  51554. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51555. /** Creates the node editor window. */
  51556. private _createNodeEditor;
  51557. /**
  51558. * Launch the node material editor
  51559. * @param config Define the configuration of the editor
  51560. * @return a promise fulfilled when the node editor is visible
  51561. */
  51562. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51563. /**
  51564. * Clear the current material
  51565. */
  51566. clear(): void;
  51567. /**
  51568. * Clear the current material and set it to a default state
  51569. */
  51570. setToDefault(): void;
  51571. private _gatherBlocks;
  51572. /**
  51573. * Serializes this material in a JSON representation
  51574. * @returns the serialized material object
  51575. */
  51576. serialize(): any;
  51577. /**
  51578. * Clear the current graph and load a new one from a serialization object
  51579. * @param source defines the JSON representation of the material
  51580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51581. */
  51582. loadFromSerialization(source: any, rootUrl?: string): void;
  51583. /**
  51584. * Creates a node material from parsed material data
  51585. * @param source defines the JSON representation of the material
  51586. * @param scene defines the hosting scene
  51587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51588. * @returns a new node material
  51589. */
  51590. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51591. }
  51592. }
  51593. declare module BABYLON {
  51594. /**
  51595. * Block used to read a texture from a sampler
  51596. */
  51597. export class TextureBlock extends NodeMaterialBlock {
  51598. private _defineName;
  51599. private _samplerName;
  51600. private _transformedUVName;
  51601. private _textureTransformName;
  51602. private _textureInfoName;
  51603. private _mainUVName;
  51604. private _mainUVDefineName;
  51605. /**
  51606. * Gets or sets the texture associated with the node
  51607. */
  51608. texture: Nullable<BaseTexture>;
  51609. /**
  51610. * Create a new TextureBlock
  51611. * @param name defines the block name
  51612. */
  51613. constructor(name: string);
  51614. /**
  51615. * Gets the current class name
  51616. * @returns the class name
  51617. */
  51618. getClassName(): string;
  51619. /**
  51620. * Gets the uv input component
  51621. */
  51622. readonly uv: NodeMaterialConnectionPoint;
  51623. /**
  51624. * Gets the output component
  51625. */
  51626. readonly output: NodeMaterialConnectionPoint;
  51627. autoConfigure(): void;
  51628. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51630. isReady(): boolean;
  51631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51632. private _injectVertexCode;
  51633. private _writeOutput;
  51634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51635. serialize(): any;
  51636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51637. }
  51638. }
  51639. declare module BABYLON {
  51640. /**
  51641. * Class used to store shared data between 2 NodeMaterialBuildState
  51642. */
  51643. export class NodeMaterialBuildStateSharedData {
  51644. /**
  51645. * Gets the list of emitted varyings
  51646. */
  51647. varyings: string[];
  51648. /**
  51649. * Gets the varying declaration string
  51650. */
  51651. varyingDeclaration: string;
  51652. /**
  51653. * Input blocks
  51654. */
  51655. inputBlocks: InputBlock[];
  51656. /**
  51657. * Input blocks
  51658. */
  51659. textureBlocks: TextureBlock[];
  51660. /**
  51661. * Bindable blocks (Blocks that need to set data to the effect)
  51662. */
  51663. bindableBlocks: NodeMaterialBlock[];
  51664. /**
  51665. * List of blocks that can provide a compilation fallback
  51666. */
  51667. blocksWithFallbacks: NodeMaterialBlock[];
  51668. /**
  51669. * List of blocks that can provide a define update
  51670. */
  51671. blocksWithDefines: NodeMaterialBlock[];
  51672. /**
  51673. * List of blocks that can provide a repeatable content
  51674. */
  51675. repeatableContentBlocks: NodeMaterialBlock[];
  51676. /**
  51677. * List of blocks that can provide a dynamic list of uniforms
  51678. */
  51679. dynamicUniformBlocks: NodeMaterialBlock[];
  51680. /**
  51681. * List of blocks that can block the isReady function for the material
  51682. */
  51683. blockingBlocks: NodeMaterialBlock[];
  51684. /**
  51685. * Build Id used to avoid multiple recompilations
  51686. */
  51687. buildId: number;
  51688. /** List of emitted variables */
  51689. variableNames: {
  51690. [key: string]: number;
  51691. };
  51692. /** List of emitted defines */
  51693. defineNames: {
  51694. [key: string]: number;
  51695. };
  51696. /** Should emit comments? */
  51697. emitComments: boolean;
  51698. /** Emit build activity */
  51699. verbose: boolean;
  51700. /**
  51701. * Gets the compilation hints emitted at compilation time
  51702. */
  51703. hints: {
  51704. needWorldViewMatrix: boolean;
  51705. needWorldViewProjectionMatrix: boolean;
  51706. needAlphaBlending: boolean;
  51707. needAlphaTesting: boolean;
  51708. };
  51709. /**
  51710. * List of compilation checks
  51711. */
  51712. checks: {
  51713. emitVertex: boolean;
  51714. emitFragment: boolean;
  51715. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51716. };
  51717. /** Creates a new shared data */
  51718. constructor();
  51719. /**
  51720. * Emits console errors and exceptions if there is a failing check
  51721. */
  51722. emitErrors(): void;
  51723. }
  51724. }
  51725. declare module BABYLON {
  51726. /**
  51727. * Class used to store node based material build state
  51728. */
  51729. export class NodeMaterialBuildState {
  51730. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51731. supportUniformBuffers: boolean;
  51732. /**
  51733. * Gets the list of emitted attributes
  51734. */
  51735. attributes: string[];
  51736. /**
  51737. * Gets the list of emitted uniforms
  51738. */
  51739. uniforms: string[];
  51740. /**
  51741. * Gets the list of emitted uniform buffers
  51742. */
  51743. uniformBuffers: string[];
  51744. /**
  51745. * Gets the list of emitted samplers
  51746. */
  51747. samplers: string[];
  51748. /**
  51749. * Gets the list of emitted functions
  51750. */
  51751. functions: {
  51752. [key: string]: string;
  51753. };
  51754. /**
  51755. * Gets the target of the compilation state
  51756. */
  51757. target: NodeMaterialBlockTargets;
  51758. /**
  51759. * Gets the list of emitted counters
  51760. */
  51761. counters: {
  51762. [key: string]: number;
  51763. };
  51764. /**
  51765. * Shared data between multiple NodeMaterialBuildState instances
  51766. */
  51767. sharedData: NodeMaterialBuildStateSharedData;
  51768. /** @hidden */
  51769. _vertexState: NodeMaterialBuildState;
  51770. /** @hidden */
  51771. _attributeDeclaration: string;
  51772. /** @hidden */
  51773. _uniformDeclaration: string;
  51774. /** @hidden */
  51775. _samplerDeclaration: string;
  51776. /** @hidden */
  51777. _varyingTransfer: string;
  51778. private _repeatableContentAnchorIndex;
  51779. /** @hidden */
  51780. _builtCompilationString: string;
  51781. /**
  51782. * Gets the emitted compilation strings
  51783. */
  51784. compilationString: string;
  51785. /**
  51786. * Finalize the compilation strings
  51787. * @param state defines the current compilation state
  51788. */
  51789. finalize(state: NodeMaterialBuildState): void;
  51790. /** @hidden */
  51791. readonly _repeatableContentAnchor: string;
  51792. /** @hidden */
  51793. _getFreeVariableName(prefix: string): string;
  51794. /** @hidden */
  51795. _getFreeDefineName(prefix: string): string;
  51796. /** @hidden */
  51797. _excludeVariableName(name: string): void;
  51798. /** @hidden */
  51799. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51800. /** @hidden */
  51801. _emitFunction(name: string, code: string, comments: string): void;
  51802. /** @hidden */
  51803. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51804. replaceStrings?: {
  51805. search: RegExp;
  51806. replace: string;
  51807. }[];
  51808. repeatKey?: string;
  51809. }): string;
  51810. /** @hidden */
  51811. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51812. repeatKey?: string;
  51813. removeAttributes?: boolean;
  51814. removeUniforms?: boolean;
  51815. removeVaryings?: boolean;
  51816. removeIfDef?: boolean;
  51817. replaceStrings?: {
  51818. search: RegExp;
  51819. replace: string;
  51820. }[];
  51821. }, storeKey?: string): void;
  51822. /** @hidden */
  51823. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51824. /** @hidden */
  51825. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51826. }
  51827. }
  51828. declare module BABYLON {
  51829. /**
  51830. * Defines a block that can be used inside a node based material
  51831. */
  51832. export class NodeMaterialBlock {
  51833. private _buildId;
  51834. private _buildTarget;
  51835. private _target;
  51836. private _isFinalMerger;
  51837. private _isInput;
  51838. /** @hidden */
  51839. _inputs: NodeMaterialConnectionPoint[];
  51840. /** @hidden */
  51841. _outputs: NodeMaterialConnectionPoint[];
  51842. /**
  51843. * Gets or sets the name of the block
  51844. */
  51845. name: string;
  51846. /**
  51847. * Gets or sets the unique id of the node
  51848. */
  51849. uniqueId: number;
  51850. /**
  51851. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51852. */
  51853. readonly isFinalMerger: boolean;
  51854. /**
  51855. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51856. */
  51857. readonly isInput: boolean;
  51858. /**
  51859. * Gets or sets the build Id
  51860. */
  51861. buildId: number;
  51862. /**
  51863. * Gets or sets the target of the block
  51864. */
  51865. target: NodeMaterialBlockTargets;
  51866. /**
  51867. * Gets the list of input points
  51868. */
  51869. readonly inputs: NodeMaterialConnectionPoint[];
  51870. /** Gets the list of output points */
  51871. readonly outputs: NodeMaterialConnectionPoint[];
  51872. /**
  51873. * Find an input by its name
  51874. * @param name defines the name of the input to look for
  51875. * @returns the input or null if not found
  51876. */
  51877. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51878. /**
  51879. * Find an output by its name
  51880. * @param name defines the name of the outputto look for
  51881. * @returns the output or null if not found
  51882. */
  51883. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51884. /**
  51885. * Creates a new NodeMaterialBlock
  51886. * @param name defines the block name
  51887. * @param target defines the target of that block (Vertex by default)
  51888. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51889. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51890. */
  51891. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51892. /**
  51893. * Initialize the block and prepare the context for build
  51894. * @param state defines the state that will be used for the build
  51895. */
  51896. initialize(state: NodeMaterialBuildState): void;
  51897. /**
  51898. * Bind data to effect. Will only be called for blocks with isBindable === true
  51899. * @param effect defines the effect to bind data to
  51900. * @param nodeMaterial defines the hosting NodeMaterial
  51901. * @param mesh defines the mesh that will be rendered
  51902. */
  51903. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51904. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51905. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51906. protected _writeFloat(value: number): string;
  51907. /**
  51908. * Gets the current class name e.g. "NodeMaterialBlock"
  51909. * @returns the class name
  51910. */
  51911. getClassName(): string;
  51912. /**
  51913. * Register a new input. Must be called inside a block constructor
  51914. * @param name defines the connection point name
  51915. * @param type defines the connection point type
  51916. * @param isOptional defines a boolean indicating that this input can be omitted
  51917. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51918. * @returns the current block
  51919. */
  51920. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51921. /**
  51922. * Register a new output. Must be called inside a block constructor
  51923. * @param name defines the connection point name
  51924. * @param type defines the connection point type
  51925. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51926. * @returns the current block
  51927. */
  51928. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51929. /**
  51930. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51931. * @param forOutput defines an optional connection point to check compatibility with
  51932. * @returns the first available input or null
  51933. */
  51934. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51935. /**
  51936. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51937. * @param forBlock defines an optional block to check compatibility with
  51938. * @returns the first available input or null
  51939. */
  51940. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51941. /**
  51942. * Connect current block with another block
  51943. * @param other defines the block to connect with
  51944. * @param options define the various options to help pick the right connections
  51945. * @returns the current block
  51946. */
  51947. connectTo(other: NodeMaterialBlock, options?: {
  51948. input?: string;
  51949. output?: string;
  51950. outputSwizzle?: string;
  51951. }): this | undefined;
  51952. protected _buildBlock(state: NodeMaterialBuildState): void;
  51953. /**
  51954. * Add uniforms, samplers and uniform buffers at compilation time
  51955. * @param state defines the state to update
  51956. * @param nodeMaterial defines the node material requesting the update
  51957. * @param defines defines the material defines to update
  51958. */
  51959. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51960. /**
  51961. * Add potential fallbacks if shader compilation fails
  51962. * @param mesh defines the mesh to be rendered
  51963. * @param fallbacks defines the current prioritized list of fallbacks
  51964. */
  51965. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51966. /**
  51967. * Update defines for shader compilation
  51968. * @param mesh defines the mesh to be rendered
  51969. * @param nodeMaterial defines the node material requesting the update
  51970. * @param defines defines the material defines to update
  51971. * @param useInstances specifies that instances should be used
  51972. */
  51973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51974. /**
  51975. * Initialize defines for shader compilation
  51976. * @param mesh defines the mesh to be rendered
  51977. * @param nodeMaterial defines the node material requesting the update
  51978. * @param defines defines the material defines to be prepared
  51979. * @param useInstances specifies that instances should be used
  51980. */
  51981. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51982. /**
  51983. * Lets the block try to connect some inputs automatically
  51984. */
  51985. autoConfigure(): void;
  51986. /**
  51987. * Function called when a block is declared as repeatable content generator
  51988. * @param vertexShaderState defines the current compilation state for the vertex shader
  51989. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51990. * @param mesh defines the mesh to be rendered
  51991. * @param defines defines the material defines to update
  51992. */
  51993. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51994. /**
  51995. * Checks if the block is ready
  51996. * @param mesh defines the mesh to be rendered
  51997. * @param nodeMaterial defines the node material requesting the update
  51998. * @param defines defines the material defines to update
  51999. * @param useInstances specifies that instances should be used
  52000. * @returns true if the block is ready
  52001. */
  52002. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52003. private _processBuild;
  52004. /**
  52005. * Compile the current node and generate the shader code
  52006. * @param state defines the current compilation state (uniforms, samplers, current string)
  52007. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  52008. * @returns true if already built
  52009. */
  52010. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  52011. /**
  52012. * Serializes this block in a JSON representation
  52013. * @returns the serialized block object
  52014. */
  52015. serialize(): any;
  52016. /** @hidden */
  52017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52018. }
  52019. }
  52020. declare module BABYLON {
  52021. /**
  52022. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52023. */
  52024. export enum NodeMaterialBlockConnectionPointMode {
  52025. /** Value is an uniform */
  52026. Uniform = 0,
  52027. /** Value is a mesh attribute */
  52028. Attribute = 1,
  52029. /** Value is a varying between vertex and fragment shaders */
  52030. Varying = 2,
  52031. /** Mode is undefined */
  52032. Undefined = 3
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. /**
  52037. * Enum used to define well known values e.g. values automatically provided by the system
  52038. */
  52039. export enum NodeMaterialWellKnownValues {
  52040. /** World */
  52041. World = 1,
  52042. /** View */
  52043. View = 2,
  52044. /** Projection */
  52045. Projection = 3,
  52046. /** ViewProjection */
  52047. ViewProjection = 4,
  52048. /** WorldView */
  52049. WorldView = 5,
  52050. /** WorldViewProjection */
  52051. WorldViewProjection = 6,
  52052. /** CameraPosition */
  52053. CameraPosition = 7,
  52054. /** Fog Color */
  52055. FogColor = 8
  52056. }
  52057. }
  52058. declare module BABYLON {
  52059. /**
  52060. * Contains position and normal vectors for a vertex
  52061. */
  52062. export class PositionNormalVertex {
  52063. /** the position of the vertex (defaut: 0,0,0) */
  52064. position: Vector3;
  52065. /** the normal of the vertex (defaut: 0,1,0) */
  52066. normal: Vector3;
  52067. /**
  52068. * Creates a PositionNormalVertex
  52069. * @param position the position of the vertex (defaut: 0,0,0)
  52070. * @param normal the normal of the vertex (defaut: 0,1,0)
  52071. */
  52072. constructor(
  52073. /** the position of the vertex (defaut: 0,0,0) */
  52074. position?: Vector3,
  52075. /** the normal of the vertex (defaut: 0,1,0) */
  52076. normal?: Vector3);
  52077. /**
  52078. * Clones the PositionNormalVertex
  52079. * @returns the cloned PositionNormalVertex
  52080. */
  52081. clone(): PositionNormalVertex;
  52082. }
  52083. /**
  52084. * Contains position, normal and uv vectors for a vertex
  52085. */
  52086. export class PositionNormalTextureVertex {
  52087. /** the position of the vertex (defaut: 0,0,0) */
  52088. position: Vector3;
  52089. /** the normal of the vertex (defaut: 0,1,0) */
  52090. normal: Vector3;
  52091. /** the uv of the vertex (default: 0,0) */
  52092. uv: Vector2;
  52093. /**
  52094. * Creates a PositionNormalTextureVertex
  52095. * @param position the position of the vertex (defaut: 0,0,0)
  52096. * @param normal the normal of the vertex (defaut: 0,1,0)
  52097. * @param uv the uv of the vertex (default: 0,0)
  52098. */
  52099. constructor(
  52100. /** the position of the vertex (defaut: 0,0,0) */
  52101. position?: Vector3,
  52102. /** the normal of the vertex (defaut: 0,1,0) */
  52103. normal?: Vector3,
  52104. /** the uv of the vertex (default: 0,0) */
  52105. uv?: Vector2);
  52106. /**
  52107. * Clones the PositionNormalTextureVertex
  52108. * @returns the cloned PositionNormalTextureVertex
  52109. */
  52110. clone(): PositionNormalTextureVertex;
  52111. }
  52112. }
  52113. declare module BABYLON {
  52114. /**
  52115. * Block used to expose an input value
  52116. */
  52117. export class InputBlock extends NodeMaterialBlock {
  52118. private _mode;
  52119. private _associatedVariableName;
  52120. private _storedValue;
  52121. private _valueCallback;
  52122. private _type;
  52123. /** @hidden */
  52124. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52125. /**
  52126. * Gets or sets the connection point type (default is float)
  52127. */
  52128. readonly type: NodeMaterialBlockConnectionPointTypes;
  52129. /**
  52130. * Creates a new InputBlock
  52131. * @param name defines the block name
  52132. * @param target defines the target of that block (Vertex by default)
  52133. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52134. */
  52135. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52136. /**
  52137. * Gets the output component
  52138. */
  52139. readonly output: NodeMaterialConnectionPoint;
  52140. /**
  52141. * Set the source of this connection point to a vertex attribute
  52142. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52143. * @returns the current connection point
  52144. */
  52145. setAsAttribute(attributeName?: string): InputBlock;
  52146. /**
  52147. * Set the source of this connection point to a well known value
  52148. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52149. * @returns the current connection point
  52150. */
  52151. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52152. /**
  52153. * Gets or sets the value of that point.
  52154. * Please note that this value will be ignored if valueCallback is defined
  52155. */
  52156. value: any;
  52157. /**
  52158. * Gets or sets a callback used to get the value of that point.
  52159. * Please note that setting this value will force the connection point to ignore the value property
  52160. */
  52161. valueCallback: () => any;
  52162. /**
  52163. * Gets or sets the associated variable name in the shader
  52164. */
  52165. associatedVariableName: string;
  52166. /**
  52167. * Gets a boolean indicating that this connection point not defined yet
  52168. */
  52169. readonly isUndefined: boolean;
  52170. /**
  52171. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52172. * In this case the connection point name must be the name of the uniform to use.
  52173. * Can only be set on inputs
  52174. */
  52175. isUniform: boolean;
  52176. /**
  52177. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52178. * In this case the connection point name must be the name of the attribute to use
  52179. * Can only be set on inputs
  52180. */
  52181. isAttribute: boolean;
  52182. /**
  52183. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52184. * Can only be set on exit points
  52185. */
  52186. isVarying: boolean;
  52187. /**
  52188. * Gets a boolean indicating that the current connection point is a well known value
  52189. */
  52190. readonly isWellKnownValue: boolean;
  52191. /**
  52192. * Gets or sets the current well known value or null if not defined as well know value
  52193. */
  52194. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52195. /**
  52196. * Gets the current class name
  52197. * @returns the class name
  52198. */
  52199. getClassName(): string;
  52200. private _emitDefine;
  52201. /**
  52202. * Set the input block to its default value (based on its type)
  52203. */
  52204. setDefaultValue(): void;
  52205. private _emit;
  52206. /** @hidden */
  52207. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52208. /** @hidden */
  52209. _transmit(effect: Effect, scene: Scene): void;
  52210. protected _buildBlock(state: NodeMaterialBuildState): void;
  52211. serialize(): any;
  52212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52213. }
  52214. }
  52215. declare module BABYLON {
  52216. /**
  52217. * Defines a connection point for a block
  52218. */
  52219. export class NodeMaterialConnectionPoint {
  52220. /** @hidden */
  52221. _ownerBlock: NodeMaterialBlock;
  52222. /** @hidden */
  52223. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52224. private _endpoints;
  52225. private _associatedVariableName;
  52226. /** @hidden */
  52227. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52228. private _type;
  52229. /** @hidden */
  52230. _enforceAssociatedVariableName: boolean;
  52231. /**
  52232. * Gets or sets the additional types supported byt this connection point
  52233. */
  52234. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52235. /**
  52236. * Gets or sets the associated variable name in the shader
  52237. */
  52238. associatedVariableName: string;
  52239. /**
  52240. * Gets or sets the connection point type (default is float)
  52241. */
  52242. type: NodeMaterialBlockConnectionPointTypes;
  52243. /**
  52244. * Gets or sets the connection point name
  52245. */
  52246. name: string;
  52247. /**
  52248. * Gets or sets a boolean indicating that this connection point can be omitted
  52249. */
  52250. isOptional: boolean;
  52251. /**
  52252. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52253. */
  52254. define: string;
  52255. /** Gets or sets the target of that connection point */
  52256. target: NodeMaterialBlockTargets;
  52257. /**
  52258. * Gets a boolean indicating that the current point is connected
  52259. */
  52260. readonly isConnected: boolean;
  52261. /**
  52262. * Gets a boolean indicating that the current point is connected to an input block
  52263. */
  52264. readonly isConnectedToInput: boolean;
  52265. /**
  52266. * Gets a the connected input block (if any)
  52267. */
  52268. readonly connectInputBlock: Nullable<InputBlock>;
  52269. /** Get the other side of the connection (if any) */
  52270. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52271. /** Get the block that owns this connection point */
  52272. readonly ownerBlock: NodeMaterialBlock;
  52273. /** Get the block connected on the other side of this connection (if any) */
  52274. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52275. /** Get the block connected on the endpoints of this connection (if any) */
  52276. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52277. /** Gets the list of connected endpoints */
  52278. readonly endpoints: NodeMaterialConnectionPoint[];
  52279. /**
  52280. * Creates a new connection point
  52281. * @param name defines the connection point name
  52282. * @param ownerBlock defines the block hosting this connection point
  52283. */
  52284. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52285. /**
  52286. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52287. * @returns the class name
  52288. */
  52289. getClassName(): string;
  52290. /**
  52291. * Gets an boolean indicating if the current point can be connected to another point
  52292. * @param connectionPoint defines the other connection point
  52293. * @returns true if the connection is possible
  52294. */
  52295. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52296. /**
  52297. * Connect this point to another connection point
  52298. * @param connectionPoint defines the other connection point
  52299. * @returns the current connection point
  52300. */
  52301. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52302. /**
  52303. * Disconnect this point from one of his endpoint
  52304. * @param endpoint defines the other connection point
  52305. * @returns the current connection point
  52306. */
  52307. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52308. /**
  52309. * Serializes this point in a JSON representation
  52310. * @returns the serialized point object
  52311. */
  52312. serialize(): any;
  52313. }
  52314. }
  52315. declare module BABYLON {
  52316. /**
  52317. * Block used to add support for vertex skinning (bones)
  52318. */
  52319. export class BonesBlock extends NodeMaterialBlock {
  52320. /**
  52321. * Creates a new BonesBlock
  52322. * @param name defines the block name
  52323. */
  52324. constructor(name: string);
  52325. /**
  52326. * Initialize the block and prepare the context for build
  52327. * @param state defines the state that will be used for the build
  52328. */
  52329. initialize(state: NodeMaterialBuildState): void;
  52330. /**
  52331. * Gets the current class name
  52332. * @returns the class name
  52333. */
  52334. getClassName(): string;
  52335. /**
  52336. * Gets the matrix indices input component
  52337. */
  52338. readonly matricesIndices: NodeMaterialConnectionPoint;
  52339. /**
  52340. * Gets the matrix weights input component
  52341. */
  52342. readonly matricesWeights: NodeMaterialConnectionPoint;
  52343. /**
  52344. * Gets the extra matrix indices input component
  52345. */
  52346. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52347. /**
  52348. * Gets the extra matrix weights input component
  52349. */
  52350. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52351. /**
  52352. * Gets the world input component
  52353. */
  52354. readonly world: NodeMaterialConnectionPoint;
  52355. /**
  52356. * Gets the output component
  52357. */
  52358. readonly output: NodeMaterialConnectionPoint;
  52359. autoConfigure(): void;
  52360. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52363. protected _buildBlock(state: NodeMaterialBuildState): this;
  52364. }
  52365. }
  52366. declare module BABYLON {
  52367. /**
  52368. * Block used to add support for instances
  52369. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52370. */
  52371. export class InstancesBlock extends NodeMaterialBlock {
  52372. /**
  52373. * Creates a new InstancesBlock
  52374. * @param name defines the block name
  52375. */
  52376. constructor(name: string);
  52377. /**
  52378. * Gets the current class name
  52379. * @returns the class name
  52380. */
  52381. getClassName(): string;
  52382. /**
  52383. * Gets the first world row input component
  52384. */
  52385. readonly world0: NodeMaterialConnectionPoint;
  52386. /**
  52387. * Gets the second world row input component
  52388. */
  52389. readonly world1: NodeMaterialConnectionPoint;
  52390. /**
  52391. * Gets the third world row input component
  52392. */
  52393. readonly world2: NodeMaterialConnectionPoint;
  52394. /**
  52395. * Gets the forth world row input component
  52396. */
  52397. readonly world3: NodeMaterialConnectionPoint;
  52398. /**
  52399. * Gets the world input component
  52400. */
  52401. readonly world: NodeMaterialConnectionPoint;
  52402. /**
  52403. * Gets the output component
  52404. */
  52405. readonly output: NodeMaterialConnectionPoint;
  52406. autoConfigure(): void;
  52407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52408. protected _buildBlock(state: NodeMaterialBuildState): this;
  52409. }
  52410. }
  52411. declare module BABYLON {
  52412. /**
  52413. * Block used to add morph targets support to vertex shader
  52414. */
  52415. export class MorphTargetsBlock extends NodeMaterialBlock {
  52416. private _repeatableContentAnchor;
  52417. private _repeatebleContentGenerated;
  52418. /**
  52419. * Create a new MorphTargetsBlock
  52420. * @param name defines the block name
  52421. */
  52422. constructor(name: string);
  52423. /**
  52424. * Gets the current class name
  52425. * @returns the class name
  52426. */
  52427. getClassName(): string;
  52428. /**
  52429. * Gets the position input component
  52430. */
  52431. readonly position: NodeMaterialConnectionPoint;
  52432. /**
  52433. * Gets the normal input component
  52434. */
  52435. readonly normal: NodeMaterialConnectionPoint;
  52436. /**
  52437. * Gets the tangent input component
  52438. */
  52439. readonly tangent: NodeMaterialConnectionPoint;
  52440. /**
  52441. * Gets the tangent input component
  52442. */
  52443. readonly uv: NodeMaterialConnectionPoint;
  52444. /**
  52445. * Gets the position output component
  52446. */
  52447. readonly positionOutput: NodeMaterialConnectionPoint;
  52448. /**
  52449. * Gets the normal output component
  52450. */
  52451. readonly normalOutput: NodeMaterialConnectionPoint;
  52452. /**
  52453. * Gets the tangent output component
  52454. */
  52455. readonly tangentOutput: NodeMaterialConnectionPoint;
  52456. /**
  52457. * Gets the tangent output component
  52458. */
  52459. readonly uvOutput: NodeMaterialConnectionPoint;
  52460. initialize(state: NodeMaterialBuildState): void;
  52461. autoConfigure(): void;
  52462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52464. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52465. protected _buildBlock(state: NodeMaterialBuildState): this;
  52466. }
  52467. }
  52468. declare module BABYLON {
  52469. /**
  52470. * Block used to add an alpha test in the fragment shader
  52471. */
  52472. export class AlphaTestBlock extends NodeMaterialBlock {
  52473. /**
  52474. * Gets or sets the alpha value where alpha testing happens
  52475. */
  52476. alphaCutOff: number;
  52477. /**
  52478. * Create a new AlphaTestBlock
  52479. * @param name defines the block name
  52480. */
  52481. constructor(name: string);
  52482. /**
  52483. * Gets the current class name
  52484. * @returns the class name
  52485. */
  52486. getClassName(): string;
  52487. /**
  52488. * Gets the color input component
  52489. */
  52490. readonly color: NodeMaterialConnectionPoint;
  52491. /**
  52492. * Gets the alpha input component
  52493. */
  52494. readonly alpha: NodeMaterialConnectionPoint;
  52495. protected _buildBlock(state: NodeMaterialBuildState): this;
  52496. }
  52497. }
  52498. declare module BABYLON {
  52499. /**
  52500. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52501. */
  52502. export class ColorMergerBlock extends NodeMaterialBlock {
  52503. /**
  52504. * Create a new ColorMergerBlock
  52505. * @param name defines the block name
  52506. */
  52507. constructor(name: string);
  52508. /**
  52509. * Gets the current class name
  52510. * @returns the class name
  52511. */
  52512. getClassName(): string;
  52513. /**
  52514. * Gets the r component (input)
  52515. */
  52516. readonly r: NodeMaterialConnectionPoint;
  52517. /**
  52518. * Gets the g component (input)
  52519. */
  52520. readonly g: NodeMaterialConnectionPoint;
  52521. /**
  52522. * Gets the b component (input)
  52523. */
  52524. readonly b: NodeMaterialConnectionPoint;
  52525. /**
  52526. * Gets the a component (input)
  52527. */
  52528. readonly a: NodeMaterialConnectionPoint;
  52529. /**
  52530. * Gets the rgba component (output)
  52531. */
  52532. readonly rgba: NodeMaterialConnectionPoint;
  52533. /**
  52534. * Gets the rgb component (output)
  52535. */
  52536. readonly rgb: NodeMaterialConnectionPoint;
  52537. protected _buildBlock(state: NodeMaterialBuildState): this;
  52538. }
  52539. }
  52540. declare module BABYLON {
  52541. /**
  52542. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52543. */
  52544. export class VectorMergerBlock extends NodeMaterialBlock {
  52545. /**
  52546. * Create a new VectorMergerBlock
  52547. * @param name defines the block name
  52548. */
  52549. constructor(name: string);
  52550. /**
  52551. * Gets the current class name
  52552. * @returns the class name
  52553. */
  52554. getClassName(): string;
  52555. /**
  52556. * Gets the x component (input)
  52557. */
  52558. readonly x: NodeMaterialConnectionPoint;
  52559. /**
  52560. * Gets the y component (input)
  52561. */
  52562. readonly y: NodeMaterialConnectionPoint;
  52563. /**
  52564. * Gets the z component (input)
  52565. */
  52566. readonly z: NodeMaterialConnectionPoint;
  52567. /**
  52568. * Gets the w component (input)
  52569. */
  52570. readonly w: NodeMaterialConnectionPoint;
  52571. /**
  52572. * Gets the xyzw component (output)
  52573. */
  52574. readonly xyzw: NodeMaterialConnectionPoint;
  52575. /**
  52576. * Gets the xyz component (output)
  52577. */
  52578. readonly xyz: NodeMaterialConnectionPoint;
  52579. /**
  52580. * Gets the xy component (output)
  52581. */
  52582. readonly xy: NodeMaterialConnectionPoint;
  52583. protected _buildBlock(state: NodeMaterialBuildState): this;
  52584. }
  52585. }
  52586. declare module BABYLON {
  52587. /**
  52588. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  52589. */
  52590. export class ColorSplitterBlock extends NodeMaterialBlock {
  52591. /**
  52592. * Create a new ColorSplitterBlock
  52593. * @param name defines the block name
  52594. */
  52595. constructor(name: string);
  52596. /**
  52597. * Gets the current class name
  52598. * @returns the class name
  52599. */
  52600. getClassName(): string;
  52601. /**
  52602. * Gets the rgba component (input)
  52603. */
  52604. readonly rgba: NodeMaterialConnectionPoint;
  52605. /**
  52606. * Gets the rgb component (input)
  52607. */
  52608. readonly rgbIn: NodeMaterialConnectionPoint;
  52609. /**
  52610. * Gets the rgb component (output)
  52611. */
  52612. readonly rgbOut: NodeMaterialConnectionPoint;
  52613. /**
  52614. * Gets the r component (output)
  52615. */
  52616. readonly r: NodeMaterialConnectionPoint;
  52617. /**
  52618. * Gets the g component (output)
  52619. */
  52620. readonly g: NodeMaterialConnectionPoint;
  52621. /**
  52622. * Gets the b component (output)
  52623. */
  52624. readonly b: NodeMaterialConnectionPoint;
  52625. /**
  52626. * Gets the a component (output)
  52627. */
  52628. readonly a: NodeMaterialConnectionPoint;
  52629. protected _buildBlock(state: NodeMaterialBuildState): this;
  52630. }
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  52635. */
  52636. export class VectorSplitterBlock extends NodeMaterialBlock {
  52637. /**
  52638. * Create a new VectorSplitterBlock
  52639. * @param name defines the block name
  52640. */
  52641. constructor(name: string);
  52642. /**
  52643. * Gets the current class name
  52644. * @returns the class name
  52645. */
  52646. getClassName(): string;
  52647. /**
  52648. * Gets the xyzw component (input)
  52649. */
  52650. readonly xyzw: NodeMaterialConnectionPoint;
  52651. /**
  52652. * Gets the xyz component (input)
  52653. */
  52654. readonly xyzIn: NodeMaterialConnectionPoint;
  52655. /**
  52656. * Gets the xyz component (output)
  52657. */
  52658. readonly xyzOut: NodeMaterialConnectionPoint;
  52659. /**
  52660. * Gets the xy component (output)
  52661. */
  52662. readonly xy: NodeMaterialConnectionPoint;
  52663. /**
  52664. * Gets the x component (output)
  52665. */
  52666. readonly x: NodeMaterialConnectionPoint;
  52667. /**
  52668. * Gets the y component (output)
  52669. */
  52670. readonly y: NodeMaterialConnectionPoint;
  52671. /**
  52672. * Gets the z component (output)
  52673. */
  52674. readonly z: NodeMaterialConnectionPoint;
  52675. /**
  52676. * Gets the w component (output)
  52677. */
  52678. readonly w: NodeMaterialConnectionPoint;
  52679. protected _buildBlock(state: NodeMaterialBuildState): this;
  52680. }
  52681. }
  52682. declare module BABYLON {
  52683. /**
  52684. * Block used to add image processing support to fragment shader
  52685. */
  52686. export class ImageProcessingBlock extends NodeMaterialBlock {
  52687. /**
  52688. * Create a new ImageProcessingBlock
  52689. * @param name defines the block name
  52690. */
  52691. constructor(name: string);
  52692. /**
  52693. * Gets the current class name
  52694. * @returns the class name
  52695. */
  52696. getClassName(): string;
  52697. /**
  52698. * Gets the color input component
  52699. */
  52700. readonly color: NodeMaterialConnectionPoint;
  52701. /**
  52702. * Gets the output component
  52703. */
  52704. readonly output: NodeMaterialConnectionPoint;
  52705. /**
  52706. * Initialize the block and prepare the context for build
  52707. * @param state defines the state that will be used for the build
  52708. */
  52709. initialize(state: NodeMaterialBuildState): void;
  52710. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52713. protected _buildBlock(state: NodeMaterialBuildState): this;
  52714. }
  52715. }
  52716. declare module BABYLON {
  52717. /**
  52718. * Block used to add support for scene fog
  52719. */
  52720. export class FogBlock extends NodeMaterialBlock {
  52721. private _fogDistanceName;
  52722. private _fogParameters;
  52723. /**
  52724. * Create a new FogBlock
  52725. * @param name defines the block name
  52726. */
  52727. constructor(name: string);
  52728. /**
  52729. * Gets the current class name
  52730. * @returns the class name
  52731. */
  52732. getClassName(): string;
  52733. /**
  52734. * Gets the world position input component
  52735. */
  52736. readonly worldPosition: NodeMaterialConnectionPoint;
  52737. /**
  52738. * Gets the view input component
  52739. */
  52740. readonly view: NodeMaterialConnectionPoint;
  52741. /**
  52742. * Gets the color input component
  52743. */
  52744. readonly color: NodeMaterialConnectionPoint;
  52745. /**
  52746. * Gets the fog color input component
  52747. */
  52748. readonly fogColor: NodeMaterialConnectionPoint;
  52749. /**
  52750. * Gets the output component
  52751. */
  52752. readonly output: NodeMaterialConnectionPoint;
  52753. autoConfigure(): void;
  52754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52756. protected _buildBlock(state: NodeMaterialBuildState): this;
  52757. }
  52758. }
  52759. declare module BABYLON {
  52760. /**
  52761. * Block used to add light in the fragment shader
  52762. */
  52763. export class LightBlock extends NodeMaterialBlock {
  52764. private _lightId;
  52765. /**
  52766. * Gets or sets the light associated with this block
  52767. */
  52768. light: Nullable<Light>;
  52769. /**
  52770. * Create a new LightBlock
  52771. * @param name defines the block name
  52772. */
  52773. constructor(name: string);
  52774. /**
  52775. * Gets the current class name
  52776. * @returns the class name
  52777. */
  52778. getClassName(): string;
  52779. /**
  52780. * Gets the world position input component
  52781. */
  52782. readonly worldPosition: NodeMaterialConnectionPoint;
  52783. /**
  52784. * Gets the world normal input component
  52785. */
  52786. readonly worldNormal: NodeMaterialConnectionPoint;
  52787. /**
  52788. * Gets the camera (or eye) position component
  52789. */
  52790. readonly cameraPosition: NodeMaterialConnectionPoint;
  52791. /**
  52792. * Gets the diffuse output component
  52793. */
  52794. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52795. /**
  52796. * Gets the specular output component
  52797. */
  52798. readonly specularOutput: NodeMaterialConnectionPoint;
  52799. autoConfigure(): void;
  52800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52801. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52803. private _injectVertexCode;
  52804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52805. serialize(): any;
  52806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * Block used to multiply 2 values
  52812. */
  52813. export class MultiplyBlock extends NodeMaterialBlock {
  52814. /**
  52815. * Creates a new MultiplyBlock
  52816. * @param name defines the block name
  52817. */
  52818. constructor(name: string);
  52819. /**
  52820. * Gets the current class name
  52821. * @returns the class name
  52822. */
  52823. getClassName(): string;
  52824. /**
  52825. * Gets the left operand input component
  52826. */
  52827. readonly left: NodeMaterialConnectionPoint;
  52828. /**
  52829. * Gets the right operand input component
  52830. */
  52831. readonly right: NodeMaterialConnectionPoint;
  52832. /**
  52833. * Gets the output component
  52834. */
  52835. readonly output: NodeMaterialConnectionPoint;
  52836. protected _buildBlock(state: NodeMaterialBuildState): this;
  52837. }
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * Block used to add 2 vectors
  52842. */
  52843. export class AddBlock extends NodeMaterialBlock {
  52844. /**
  52845. * Creates a new AddBlock
  52846. * @param name defines the block name
  52847. */
  52848. constructor(name: string);
  52849. /**
  52850. * Gets the current class name
  52851. * @returns the class name
  52852. */
  52853. getClassName(): string;
  52854. /**
  52855. * Gets the left operand input component
  52856. */
  52857. readonly left: NodeMaterialConnectionPoint;
  52858. /**
  52859. * Gets the right operand input component
  52860. */
  52861. readonly right: NodeMaterialConnectionPoint;
  52862. /**
  52863. * Gets the output component
  52864. */
  52865. readonly output: NodeMaterialConnectionPoint;
  52866. protected _buildBlock(state: NodeMaterialBuildState): this;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Block used to clamp a float
  52872. */
  52873. export class ClampBlock extends NodeMaterialBlock {
  52874. /** Gets or sets the minimum range */
  52875. minimum: number;
  52876. /** Gets or sets the maximum range */
  52877. maximum: number;
  52878. /**
  52879. * Creates a new ClampBlock
  52880. * @param name defines the block name
  52881. */
  52882. constructor(name: string);
  52883. /**
  52884. * Gets the current class name
  52885. * @returns the class name
  52886. */
  52887. getClassName(): string;
  52888. /**
  52889. * Gets the value input component
  52890. */
  52891. readonly value: NodeMaterialConnectionPoint;
  52892. /**
  52893. * Gets the output component
  52894. */
  52895. readonly output: NodeMaterialConnectionPoint;
  52896. protected _buildBlock(state: NodeMaterialBuildState): this;
  52897. }
  52898. }
  52899. declare module BABYLON {
  52900. /**
  52901. * Block used to apply a cross product between 2 vectors
  52902. */
  52903. export class CrossBlock extends NodeMaterialBlock {
  52904. /**
  52905. * Creates a new CrossBlock
  52906. * @param name defines the block name
  52907. */
  52908. constructor(name: string);
  52909. /**
  52910. * Gets the current class name
  52911. * @returns the class name
  52912. */
  52913. getClassName(): string;
  52914. /**
  52915. * Gets the left operand input component
  52916. */
  52917. readonly left: NodeMaterialConnectionPoint;
  52918. /**
  52919. * Gets the right operand input component
  52920. */
  52921. readonly right: NodeMaterialConnectionPoint;
  52922. /**
  52923. * Gets the output component
  52924. */
  52925. readonly output: NodeMaterialConnectionPoint;
  52926. protected _buildBlock(state: NodeMaterialBuildState): this;
  52927. }
  52928. }
  52929. declare module BABYLON {
  52930. /**
  52931. * Block used to apply a dot product between 2 vectors
  52932. */
  52933. export class DotBlock extends NodeMaterialBlock {
  52934. /**
  52935. * Creates a new DotBlock
  52936. * @param name defines the block name
  52937. */
  52938. constructor(name: string);
  52939. /**
  52940. * Gets the current class name
  52941. * @returns the class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Gets the left operand input component
  52946. */
  52947. readonly left: NodeMaterialConnectionPoint;
  52948. /**
  52949. * Gets the right operand input component
  52950. */
  52951. readonly right: NodeMaterialConnectionPoint;
  52952. /**
  52953. * Gets the output component
  52954. */
  52955. readonly output: NodeMaterialConnectionPoint;
  52956. protected _buildBlock(state: NodeMaterialBuildState): this;
  52957. }
  52958. }
  52959. declare module BABYLON {
  52960. /**
  52961. * Block used to remap a float from a range to a new one
  52962. */
  52963. export class RemapBlock extends NodeMaterialBlock {
  52964. /**
  52965. * Gets or sets the source range
  52966. */
  52967. sourceRange: Vector2;
  52968. /**
  52969. * Gets or sets the target range
  52970. */
  52971. targetRange: Vector2;
  52972. /**
  52973. * Creates a new RemapBlock
  52974. * @param name defines the block name
  52975. */
  52976. constructor(name: string);
  52977. /**
  52978. * Gets the current class name
  52979. * @returns the class name
  52980. */
  52981. getClassName(): string;
  52982. /**
  52983. * Gets the input component
  52984. */
  52985. readonly input: NodeMaterialConnectionPoint;
  52986. /**
  52987. * Gets the output component
  52988. */
  52989. readonly output: NodeMaterialConnectionPoint;
  52990. protected _buildBlock(state: NodeMaterialBuildState): this;
  52991. }
  52992. }
  52993. declare module BABYLON {
  52994. /**
  52995. * Block used to normalize a vector
  52996. */
  52997. export class NormalizeBlock extends NodeMaterialBlock {
  52998. /**
  52999. * Creates a new NormalizeBlock
  53000. * @param name defines the block name
  53001. */
  53002. constructor(name: string);
  53003. /**
  53004. * Gets the current class name
  53005. * @returns the class name
  53006. */
  53007. getClassName(): string;
  53008. /**
  53009. * Gets the input component
  53010. */
  53011. readonly input: NodeMaterialConnectionPoint;
  53012. /**
  53013. * Gets the output component
  53014. */
  53015. readonly output: NodeMaterialConnectionPoint;
  53016. protected _buildBlock(state: NodeMaterialBuildState): this;
  53017. }
  53018. }
  53019. declare module BABYLON {
  53020. /**
  53021. * Effect Render Options
  53022. */
  53023. export interface IEffectRendererOptions {
  53024. /**
  53025. * Defines the vertices positions.
  53026. */
  53027. positions?: number[];
  53028. /**
  53029. * Defines the indices.
  53030. */
  53031. indices?: number[];
  53032. }
  53033. /**
  53034. * Helper class to render one or more effects
  53035. */
  53036. export class EffectRenderer {
  53037. private engine;
  53038. private static _DefaultOptions;
  53039. private _vertexBuffers;
  53040. private _indexBuffer;
  53041. private _ringBufferIndex;
  53042. private _ringScreenBuffer;
  53043. private _fullscreenViewport;
  53044. private _getNextFrameBuffer;
  53045. /**
  53046. * Creates an effect renderer
  53047. * @param engine the engine to use for rendering
  53048. * @param options defines the options of the effect renderer
  53049. */
  53050. constructor(engine: Engine, options?: IEffectRendererOptions);
  53051. /**
  53052. * Sets the current viewport in normalized coordinates 0-1
  53053. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53054. */
  53055. setViewport(viewport?: Viewport): void;
  53056. /**
  53057. * Sets the current effect wrapper to use during draw.
  53058. * The effect needs to be ready before calling this api.
  53059. * This also sets the default full screen position attribute.
  53060. * @param effectWrapper Defines the effect to draw with
  53061. */
  53062. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53063. /**
  53064. * Draws a full screen quad.
  53065. */
  53066. draw(): void;
  53067. /**
  53068. * renders one or more effects to a specified texture
  53069. * @param effectWrappers list of effects to renderer
  53070. * @param outputTexture texture to draw to, if null it will render to the screen
  53071. */
  53072. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53073. /**
  53074. * Disposes of the effect renderer
  53075. */
  53076. dispose(): void;
  53077. }
  53078. /**
  53079. * Options to create an EffectWrapper
  53080. */
  53081. interface EffectWrapperCreationOptions {
  53082. /**
  53083. * Engine to use to create the effect
  53084. */
  53085. engine: Engine;
  53086. /**
  53087. * Fragment shader for the effect
  53088. */
  53089. fragmentShader: string;
  53090. /**
  53091. * Vertex shader for the effect
  53092. */
  53093. vertexShader: string;
  53094. /**
  53095. * Attributes to use in the shader
  53096. */
  53097. attributeNames?: Array<string>;
  53098. /**
  53099. * Uniforms to use in the shader
  53100. */
  53101. uniformNames?: Array<string>;
  53102. /**
  53103. * Texture sampler names to use in the shader
  53104. */
  53105. samplerNames?: Array<string>;
  53106. /**
  53107. * The friendly name of the effect displayed in Spector.
  53108. */
  53109. name?: string;
  53110. }
  53111. /**
  53112. * Wraps an effect to be used for rendering
  53113. */
  53114. export class EffectWrapper {
  53115. /**
  53116. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53117. */
  53118. onApplyObservable: Observable<{}>;
  53119. /**
  53120. * The underlying effect
  53121. */
  53122. effect: Effect;
  53123. /**
  53124. * Creates an effect to be renderer
  53125. * @param creationOptions options to create the effect
  53126. */
  53127. constructor(creationOptions: EffectWrapperCreationOptions);
  53128. /**
  53129. * Disposes of the effect wrapper
  53130. */
  53131. dispose(): void;
  53132. }
  53133. }
  53134. declare module BABYLON {
  53135. /**
  53136. * Helper class to push actions to a pool of workers.
  53137. */
  53138. export class WorkerPool implements IDisposable {
  53139. private _workerInfos;
  53140. private _pendingActions;
  53141. /**
  53142. * Constructor
  53143. * @param workers Array of workers to use for actions
  53144. */
  53145. constructor(workers: Array<Worker>);
  53146. /**
  53147. * Terminates all workers and clears any pending actions.
  53148. */
  53149. dispose(): void;
  53150. /**
  53151. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53152. * pended until a worker has completed its action.
  53153. * @param action The action to perform. Call onComplete when the action is complete.
  53154. */
  53155. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53156. private _execute;
  53157. }
  53158. }
  53159. declare module BABYLON {
  53160. /**
  53161. * Configuration for Draco compression
  53162. */
  53163. export interface IDracoCompressionConfiguration {
  53164. /**
  53165. * Configuration for the decoder.
  53166. */
  53167. decoder: {
  53168. /**
  53169. * The url to the WebAssembly module.
  53170. */
  53171. wasmUrl?: string;
  53172. /**
  53173. * The url to the WebAssembly binary.
  53174. */
  53175. wasmBinaryUrl?: string;
  53176. /**
  53177. * The url to the fallback JavaScript module.
  53178. */
  53179. fallbackUrl?: string;
  53180. };
  53181. }
  53182. /**
  53183. * Draco compression (https://google.github.io/draco/)
  53184. *
  53185. * This class wraps the Draco module.
  53186. *
  53187. * **Encoder**
  53188. *
  53189. * The encoder is not currently implemented.
  53190. *
  53191. * **Decoder**
  53192. *
  53193. * 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.
  53194. *
  53195. * To update the configuration, use the following code:
  53196. * ```javascript
  53197. * DracoCompression.Configuration = {
  53198. * decoder: {
  53199. * wasmUrl: "<url to the WebAssembly library>",
  53200. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53201. * fallbackUrl: "<url to the fallback JavaScript library>",
  53202. * }
  53203. * };
  53204. * ```
  53205. *
  53206. * 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.
  53207. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53208. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53209. *
  53210. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53211. * ```javascript
  53212. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53213. * ```
  53214. *
  53215. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53216. */
  53217. export class DracoCompression implements IDisposable {
  53218. private _workerPoolPromise?;
  53219. private _decoderModulePromise?;
  53220. /**
  53221. * The configuration. Defaults to the following urls:
  53222. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53223. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53224. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53225. */
  53226. static Configuration: IDracoCompressionConfiguration;
  53227. /**
  53228. * Returns true if the decoder configuration is available.
  53229. */
  53230. static readonly DecoderAvailable: boolean;
  53231. /**
  53232. * Default number of workers to create when creating the draco compression object.
  53233. */
  53234. static DefaultNumWorkers: number;
  53235. private static GetDefaultNumWorkers;
  53236. private static _Default;
  53237. /**
  53238. * Default instance for the draco compression object.
  53239. */
  53240. static readonly Default: DracoCompression;
  53241. /**
  53242. * Constructor
  53243. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53244. */
  53245. constructor(numWorkers?: number);
  53246. /**
  53247. * Stop all async operations and release resources.
  53248. */
  53249. dispose(): void;
  53250. /**
  53251. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53252. * @returns a promise that resolves when ready
  53253. */
  53254. whenReadyAsync(): Promise<void>;
  53255. /**
  53256. * Decode Draco compressed mesh data to vertex data.
  53257. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53258. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53259. * @returns A promise that resolves with the decoded vertex data
  53260. */
  53261. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53262. [kind: string]: number;
  53263. }): Promise<VertexData>;
  53264. }
  53265. }
  53266. declare module BABYLON {
  53267. /**
  53268. * Class for building Constructive Solid Geometry
  53269. */
  53270. export class CSG {
  53271. private polygons;
  53272. /**
  53273. * The world matrix
  53274. */
  53275. matrix: Matrix;
  53276. /**
  53277. * Stores the position
  53278. */
  53279. position: Vector3;
  53280. /**
  53281. * Stores the rotation
  53282. */
  53283. rotation: Vector3;
  53284. /**
  53285. * Stores the rotation quaternion
  53286. */
  53287. rotationQuaternion: Nullable<Quaternion>;
  53288. /**
  53289. * Stores the scaling vector
  53290. */
  53291. scaling: Vector3;
  53292. /**
  53293. * Convert the Mesh to CSG
  53294. * @param mesh The Mesh to convert to CSG
  53295. * @returns A new CSG from the Mesh
  53296. */
  53297. static FromMesh(mesh: Mesh): CSG;
  53298. /**
  53299. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53300. * @param polygons Polygons used to construct a CSG solid
  53301. */
  53302. private static FromPolygons;
  53303. /**
  53304. * Clones, or makes a deep copy, of the CSG
  53305. * @returns A new CSG
  53306. */
  53307. clone(): CSG;
  53308. /**
  53309. * Unions this CSG with another CSG
  53310. * @param csg The CSG to union against this CSG
  53311. * @returns The unioned CSG
  53312. */
  53313. union(csg: CSG): CSG;
  53314. /**
  53315. * Unions this CSG with another CSG in place
  53316. * @param csg The CSG to union against this CSG
  53317. */
  53318. unionInPlace(csg: CSG): void;
  53319. /**
  53320. * Subtracts this CSG with another CSG
  53321. * @param csg The CSG to subtract against this CSG
  53322. * @returns A new CSG
  53323. */
  53324. subtract(csg: CSG): CSG;
  53325. /**
  53326. * Subtracts this CSG with another CSG in place
  53327. * @param csg The CSG to subtact against this CSG
  53328. */
  53329. subtractInPlace(csg: CSG): void;
  53330. /**
  53331. * Intersect this CSG with another CSG
  53332. * @param csg The CSG to intersect against this CSG
  53333. * @returns A new CSG
  53334. */
  53335. intersect(csg: CSG): CSG;
  53336. /**
  53337. * Intersects this CSG with another CSG in place
  53338. * @param csg The CSG to intersect against this CSG
  53339. */
  53340. intersectInPlace(csg: CSG): void;
  53341. /**
  53342. * Return a new CSG solid with solid and empty space switched. This solid is
  53343. * not modified.
  53344. * @returns A new CSG solid with solid and empty space switched
  53345. */
  53346. inverse(): CSG;
  53347. /**
  53348. * Inverses the CSG in place
  53349. */
  53350. inverseInPlace(): void;
  53351. /**
  53352. * This is used to keep meshes transformations so they can be restored
  53353. * when we build back a Babylon Mesh
  53354. * NB : All CSG operations are performed in world coordinates
  53355. * @param csg The CSG to copy the transform attributes from
  53356. * @returns This CSG
  53357. */
  53358. copyTransformAttributes(csg: CSG): CSG;
  53359. /**
  53360. * Build Raw mesh from CSG
  53361. * Coordinates here are in world space
  53362. * @param name The name of the mesh geometry
  53363. * @param scene The Scene
  53364. * @param keepSubMeshes Specifies if the submeshes should be kept
  53365. * @returns A new Mesh
  53366. */
  53367. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53368. /**
  53369. * Build Mesh from CSG taking material and transforms into account
  53370. * @param name The name of the Mesh
  53371. * @param material The material of the Mesh
  53372. * @param scene The Scene
  53373. * @param keepSubMeshes Specifies if submeshes should be kept
  53374. * @returns The new Mesh
  53375. */
  53376. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53377. }
  53378. }
  53379. declare module BABYLON {
  53380. /**
  53381. * Class used to create a trail following a mesh
  53382. */
  53383. export class TrailMesh extends Mesh {
  53384. private _generator;
  53385. private _autoStart;
  53386. private _running;
  53387. private _diameter;
  53388. private _length;
  53389. private _sectionPolygonPointsCount;
  53390. private _sectionVectors;
  53391. private _sectionNormalVectors;
  53392. private _beforeRenderObserver;
  53393. /**
  53394. * @constructor
  53395. * @param name The value used by scene.getMeshByName() to do a lookup.
  53396. * @param generator The mesh to generate a trail.
  53397. * @param scene The scene to add this mesh to.
  53398. * @param diameter Diameter of trailing mesh. Default is 1.
  53399. * @param length Length of trailing mesh. Default is 60.
  53400. * @param autoStart Automatically start trailing mesh. Default true.
  53401. */
  53402. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53403. /**
  53404. * "TrailMesh"
  53405. * @returns "TrailMesh"
  53406. */
  53407. getClassName(): string;
  53408. private _createMesh;
  53409. /**
  53410. * Start trailing mesh.
  53411. */
  53412. start(): void;
  53413. /**
  53414. * Stop trailing mesh.
  53415. */
  53416. stop(): void;
  53417. /**
  53418. * Update trailing mesh geometry.
  53419. */
  53420. update(): void;
  53421. /**
  53422. * Returns a new TrailMesh object.
  53423. * @param name is a string, the name given to the new mesh
  53424. * @param newGenerator use new generator object for cloned trail mesh
  53425. * @returns a new mesh
  53426. */
  53427. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53428. /**
  53429. * Serializes this trail mesh
  53430. * @param serializationObject object to write serialization to
  53431. */
  53432. serialize(serializationObject: any): void;
  53433. /**
  53434. * Parses a serialized trail mesh
  53435. * @param parsedMesh the serialized mesh
  53436. * @param scene the scene to create the trail mesh in
  53437. * @returns the created trail mesh
  53438. */
  53439. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53440. }
  53441. }
  53442. declare module BABYLON {
  53443. /**
  53444. * Class containing static functions to help procedurally build meshes
  53445. */
  53446. export class TiledBoxBuilder {
  53447. /**
  53448. * Creates a box mesh
  53449. * 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)
  53450. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53452. * * 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
  53453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53454. * @param name defines the name of the mesh
  53455. * @param options defines the options used to create the mesh
  53456. * @param scene defines the hosting scene
  53457. * @returns the box mesh
  53458. */
  53459. static CreateTiledBox(name: string, options: {
  53460. pattern?: number;
  53461. width?: number;
  53462. height?: number;
  53463. depth?: number;
  53464. tileSize?: number;
  53465. tileWidth?: number;
  53466. tileHeight?: number;
  53467. alignHorizontal?: number;
  53468. alignVertical?: number;
  53469. faceUV?: Vector4[];
  53470. faceColors?: Color4[];
  53471. sideOrientation?: number;
  53472. updatable?: boolean;
  53473. }, scene?: Nullable<Scene>): Mesh;
  53474. }
  53475. }
  53476. declare module BABYLON {
  53477. /**
  53478. * Class containing static functions to help procedurally build meshes
  53479. */
  53480. export class TorusKnotBuilder {
  53481. /**
  53482. * Creates a torus knot mesh
  53483. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53484. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53485. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53486. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53488. * * 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
  53489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53490. * @param name defines the name of the mesh
  53491. * @param options defines the options used to create the mesh
  53492. * @param scene defines the hosting scene
  53493. * @returns the torus knot mesh
  53494. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53495. */
  53496. static CreateTorusKnot(name: string, options: {
  53497. radius?: number;
  53498. tube?: number;
  53499. radialSegments?: number;
  53500. tubularSegments?: number;
  53501. p?: number;
  53502. q?: number;
  53503. updatable?: boolean;
  53504. sideOrientation?: number;
  53505. frontUVs?: Vector4;
  53506. backUVs?: Vector4;
  53507. }, scene: any): Mesh;
  53508. }
  53509. }
  53510. declare module BABYLON {
  53511. /**
  53512. * Polygon
  53513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53514. */
  53515. export class Polygon {
  53516. /**
  53517. * Creates a rectangle
  53518. * @param xmin bottom X coord
  53519. * @param ymin bottom Y coord
  53520. * @param xmax top X coord
  53521. * @param ymax top Y coord
  53522. * @returns points that make the resulting rectation
  53523. */
  53524. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53525. /**
  53526. * Creates a circle
  53527. * @param radius radius of circle
  53528. * @param cx scale in x
  53529. * @param cy scale in y
  53530. * @param numberOfSides number of sides that make up the circle
  53531. * @returns points that make the resulting circle
  53532. */
  53533. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53534. /**
  53535. * Creates a polygon from input string
  53536. * @param input Input polygon data
  53537. * @returns the parsed points
  53538. */
  53539. static Parse(input: string): Vector2[];
  53540. /**
  53541. * Starts building a polygon from x and y coordinates
  53542. * @param x x coordinate
  53543. * @param y y coordinate
  53544. * @returns the started path2
  53545. */
  53546. static StartingAt(x: number, y: number): Path2;
  53547. }
  53548. /**
  53549. * Builds a polygon
  53550. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53551. */
  53552. export class PolygonMeshBuilder {
  53553. private _points;
  53554. private _outlinepoints;
  53555. private _holes;
  53556. private _name;
  53557. private _scene;
  53558. private _epoints;
  53559. private _eholes;
  53560. private _addToepoint;
  53561. /**
  53562. * Babylon reference to the earcut plugin.
  53563. */
  53564. bjsEarcut: any;
  53565. /**
  53566. * Creates a PolygonMeshBuilder
  53567. * @param name name of the builder
  53568. * @param contours Path of the polygon
  53569. * @param scene scene to add to when creating the mesh
  53570. * @param earcutInjection can be used to inject your own earcut reference
  53571. */
  53572. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53573. /**
  53574. * Adds a whole within the polygon
  53575. * @param hole Array of points defining the hole
  53576. * @returns this
  53577. */
  53578. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53579. /**
  53580. * Creates the polygon
  53581. * @param updatable If the mesh should be updatable
  53582. * @param depth The depth of the mesh created
  53583. * @returns the created mesh
  53584. */
  53585. build(updatable?: boolean, depth?: number): Mesh;
  53586. /**
  53587. * Creates the polygon
  53588. * @param depth The depth of the mesh created
  53589. * @returns the created VertexData
  53590. */
  53591. buildVertexData(depth?: number): VertexData;
  53592. /**
  53593. * Adds a side to the polygon
  53594. * @param positions points that make the polygon
  53595. * @param normals normals of the polygon
  53596. * @param uvs uvs of the polygon
  53597. * @param indices indices of the polygon
  53598. * @param bounds bounds of the polygon
  53599. * @param points points of the polygon
  53600. * @param depth depth of the polygon
  53601. * @param flip flip of the polygon
  53602. */
  53603. private addSide;
  53604. }
  53605. }
  53606. declare module BABYLON {
  53607. /**
  53608. * Class containing static functions to help procedurally build meshes
  53609. */
  53610. export class PolygonBuilder {
  53611. /**
  53612. * Creates a polygon mesh
  53613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53614. * * 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
  53615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  53618. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  53623. * @returns the polygon mesh
  53624. */
  53625. static CreatePolygon(name: string, options: {
  53626. shape: Vector3[];
  53627. holes?: Vector3[][];
  53628. depth?: number;
  53629. faceUV?: Vector4[];
  53630. faceColors?: Color4[];
  53631. updatable?: boolean;
  53632. sideOrientation?: number;
  53633. frontUVs?: Vector4;
  53634. backUVs?: Vector4;
  53635. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53636. /**
  53637. * Creates an extruded polygon mesh, with depth in the Y direction.
  53638. * * 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)
  53639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53640. * @param name defines the name of the mesh
  53641. * @param options defines the options used to create the mesh
  53642. * @param scene defines the hosting scene
  53643. * @param earcutInjection can be used to inject your own earcut reference
  53644. * @returns the polygon mesh
  53645. */
  53646. static ExtrudePolygon(name: string, options: {
  53647. shape: Vector3[];
  53648. holes?: Vector3[][];
  53649. depth?: number;
  53650. faceUV?: Vector4[];
  53651. faceColors?: Color4[];
  53652. updatable?: boolean;
  53653. sideOrientation?: number;
  53654. frontUVs?: Vector4;
  53655. backUVs?: Vector4;
  53656. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53657. }
  53658. }
  53659. declare module BABYLON {
  53660. /**
  53661. * Class containing static functions to help procedurally build meshes
  53662. */
  53663. export class LatheBuilder {
  53664. /**
  53665. * Creates lathe mesh.
  53666. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53667. * * 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
  53668. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53669. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53670. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53671. * * 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
  53672. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53673. * * 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
  53674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53675. * * 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
  53676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53678. * @param name defines the name of the mesh
  53679. * @param options defines the options used to create the mesh
  53680. * @param scene defines the hosting scene
  53681. * @returns the lathe mesh
  53682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53683. */
  53684. static CreateLathe(name: string, options: {
  53685. shape: Vector3[];
  53686. radius?: number;
  53687. tessellation?: number;
  53688. clip?: number;
  53689. arc?: number;
  53690. closed?: boolean;
  53691. updatable?: boolean;
  53692. sideOrientation?: number;
  53693. frontUVs?: Vector4;
  53694. backUVs?: Vector4;
  53695. cap?: number;
  53696. invertUV?: boolean;
  53697. }, scene?: Nullable<Scene>): Mesh;
  53698. }
  53699. }
  53700. declare module BABYLON {
  53701. /**
  53702. * Class containing static functions to help procedurally build meshes
  53703. */
  53704. export class TiledPlaneBuilder {
  53705. /**
  53706. * Creates a tiled plane mesh
  53707. * * The parameter `pattern` will, depending on value, do nothing or
  53708. * * * flip (reflect about central vertical) alternate tiles across and up
  53709. * * * flip every tile on alternate rows
  53710. * * * rotate (180 degs) alternate tiles across and up
  53711. * * * rotate every tile on alternate rows
  53712. * * * flip and rotate alternate tiles across and up
  53713. * * * flip and rotate every tile on alternate rows
  53714. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53715. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53716. * * 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
  53717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53718. * * 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)
  53719. * * 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)
  53720. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53721. * @param name defines the name of the mesh
  53722. * @param options defines the options used to create the mesh
  53723. * @param scene defines the hosting scene
  53724. * @returns the box mesh
  53725. */
  53726. static CreateTiledPlane(name: string, options: {
  53727. pattern?: number;
  53728. tileSize?: number;
  53729. tileWidth?: number;
  53730. tileHeight?: number;
  53731. size?: number;
  53732. width?: number;
  53733. height?: number;
  53734. alignHorizontal?: number;
  53735. alignVertical?: number;
  53736. sideOrientation?: number;
  53737. frontUVs?: Vector4;
  53738. backUVs?: Vector4;
  53739. updatable?: boolean;
  53740. }, scene?: Nullable<Scene>): Mesh;
  53741. }
  53742. }
  53743. declare module BABYLON {
  53744. /**
  53745. * Class containing static functions to help procedurally build meshes
  53746. */
  53747. export class TubeBuilder {
  53748. /**
  53749. * Creates a tube mesh.
  53750. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53751. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53752. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53753. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53754. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53755. * * 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)
  53756. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53757. * * 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
  53758. * * 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
  53759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53760. * * 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
  53761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53763. * @param name defines the name of the mesh
  53764. * @param options defines the options used to create the mesh
  53765. * @param scene defines the hosting scene
  53766. * @returns the tube mesh
  53767. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53768. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53769. */
  53770. static CreateTube(name: string, options: {
  53771. path: Vector3[];
  53772. radius?: number;
  53773. tessellation?: number;
  53774. radiusFunction?: {
  53775. (i: number, distance: number): number;
  53776. };
  53777. cap?: number;
  53778. arc?: number;
  53779. updatable?: boolean;
  53780. sideOrientation?: number;
  53781. frontUVs?: Vector4;
  53782. backUVs?: Vector4;
  53783. instance?: Mesh;
  53784. invertUV?: boolean;
  53785. }, scene?: Nullable<Scene>): Mesh;
  53786. }
  53787. }
  53788. declare module BABYLON {
  53789. /**
  53790. * Class containing static functions to help procedurally build meshes
  53791. */
  53792. export class IcoSphereBuilder {
  53793. /**
  53794. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53795. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53796. * * 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`)
  53797. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53798. * * 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
  53799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53800. * * 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
  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 icosahedron mesh
  53806. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53807. */
  53808. static CreateIcoSphere(name: string, options: {
  53809. radius?: number;
  53810. radiusX?: number;
  53811. radiusY?: number;
  53812. radiusZ?: number;
  53813. flat?: boolean;
  53814. subdivisions?: number;
  53815. sideOrientation?: number;
  53816. frontUVs?: Vector4;
  53817. backUVs?: Vector4;
  53818. updatable?: boolean;
  53819. }, scene?: Nullable<Scene>): Mesh;
  53820. }
  53821. }
  53822. declare module BABYLON {
  53823. /**
  53824. * Class containing static functions to help procedurally build meshes
  53825. */
  53826. export class DecalBuilder {
  53827. /**
  53828. * Creates a decal mesh.
  53829. * 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
  53830. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53831. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53832. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53833. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53834. * @param name defines the name of the mesh
  53835. * @param sourceMesh defines the mesh where the decal must be applied
  53836. * @param options defines the options used to create the mesh
  53837. * @param scene defines the hosting scene
  53838. * @returns the decal mesh
  53839. * @see https://doc.babylonjs.com/how_to/decals
  53840. */
  53841. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53842. position?: Vector3;
  53843. normal?: Vector3;
  53844. size?: Vector3;
  53845. angle?: number;
  53846. }): Mesh;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. /**
  53851. * Class containing static functions to help procedurally build meshes
  53852. */
  53853. export class MeshBuilder {
  53854. /**
  53855. * Creates a box mesh
  53856. * * The parameter `size` sets the size (float) of each box side (default 1)
  53857. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53858. * * 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)
  53859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53861. * * 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
  53862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53863. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53864. * @param name defines the name of the mesh
  53865. * @param options defines the options used to create the mesh
  53866. * @param scene defines the hosting scene
  53867. * @returns the box mesh
  53868. */
  53869. static CreateBox(name: string, options: {
  53870. size?: number;
  53871. width?: number;
  53872. height?: number;
  53873. depth?: number;
  53874. faceUV?: Vector4[];
  53875. faceColors?: Color4[];
  53876. sideOrientation?: number;
  53877. frontUVs?: Vector4;
  53878. backUVs?: Vector4;
  53879. updatable?: boolean;
  53880. }, scene?: Nullable<Scene>): Mesh;
  53881. /**
  53882. * Creates a tiled box mesh
  53883. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53885. * @param name defines the name of the mesh
  53886. * @param options defines the options used to create the mesh
  53887. * @param scene defines the hosting scene
  53888. * @returns the tiled box mesh
  53889. */
  53890. static CreateTiledBox(name: string, options: {
  53891. pattern?: number;
  53892. size?: number;
  53893. width?: number;
  53894. height?: number;
  53895. depth: number;
  53896. tileSize?: number;
  53897. tileWidth?: number;
  53898. tileHeight?: number;
  53899. faceUV?: Vector4[];
  53900. faceColors?: Color4[];
  53901. alignHorizontal?: number;
  53902. alignVertical?: number;
  53903. sideOrientation?: number;
  53904. updatable?: boolean;
  53905. }, scene?: Nullable<Scene>): Mesh;
  53906. /**
  53907. * Creates a sphere mesh
  53908. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53909. * * 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`)
  53910. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53911. * * 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
  53912. * * 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)
  53913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53914. * * 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
  53915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53916. * @param name defines the name of the mesh
  53917. * @param options defines the options used to create the mesh
  53918. * @param scene defines the hosting scene
  53919. * @returns the sphere mesh
  53920. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53921. */
  53922. static CreateSphere(name: string, options: {
  53923. segments?: number;
  53924. diameter?: number;
  53925. diameterX?: number;
  53926. diameterY?: number;
  53927. diameterZ?: number;
  53928. arc?: number;
  53929. slice?: number;
  53930. sideOrientation?: number;
  53931. frontUVs?: Vector4;
  53932. backUVs?: Vector4;
  53933. updatable?: boolean;
  53934. }, scene?: Nullable<Scene>): Mesh;
  53935. /**
  53936. * Creates a plane polygonal mesh. By default, this is a disc
  53937. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53938. * * 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
  53939. * * 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
  53940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53941. * * 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
  53942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53943. * @param name defines the name of the mesh
  53944. * @param options defines the options used to create the mesh
  53945. * @param scene defines the hosting scene
  53946. * @returns the plane polygonal mesh
  53947. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53948. */
  53949. static CreateDisc(name: string, options: {
  53950. radius?: number;
  53951. tessellation?: number;
  53952. arc?: number;
  53953. updatable?: boolean;
  53954. sideOrientation?: number;
  53955. frontUVs?: Vector4;
  53956. backUVs?: Vector4;
  53957. }, scene?: Nullable<Scene>): Mesh;
  53958. /**
  53959. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53960. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53961. * * 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`)
  53962. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53963. * * 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
  53964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53965. * * 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
  53966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53967. * @param name defines the name of the mesh
  53968. * @param options defines the options used to create the mesh
  53969. * @param scene defines the hosting scene
  53970. * @returns the icosahedron mesh
  53971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53972. */
  53973. static CreateIcoSphere(name: string, options: {
  53974. radius?: number;
  53975. radiusX?: number;
  53976. radiusY?: number;
  53977. radiusZ?: number;
  53978. flat?: boolean;
  53979. subdivisions?: number;
  53980. sideOrientation?: number;
  53981. frontUVs?: Vector4;
  53982. backUVs?: Vector4;
  53983. updatable?: boolean;
  53984. }, scene?: Nullable<Scene>): Mesh;
  53985. /**
  53986. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53987. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53988. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53989. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53990. * * 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
  53991. * * 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
  53992. * * 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
  53993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53994. * * 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
  53995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53996. * * 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
  53997. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53998. * * 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
  53999. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54001. * @param name defines the name of the mesh
  54002. * @param options defines the options used to create the mesh
  54003. * @param scene defines the hosting scene
  54004. * @returns the ribbon mesh
  54005. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54006. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54007. */
  54008. static CreateRibbon(name: string, options: {
  54009. pathArray: Vector3[][];
  54010. closeArray?: boolean;
  54011. closePath?: boolean;
  54012. offset?: number;
  54013. updatable?: boolean;
  54014. sideOrientation?: number;
  54015. frontUVs?: Vector4;
  54016. backUVs?: Vector4;
  54017. instance?: Mesh;
  54018. invertUV?: boolean;
  54019. uvs?: Vector2[];
  54020. colors?: Color4[];
  54021. }, scene?: Nullable<Scene>): Mesh;
  54022. /**
  54023. * Creates a cylinder or a cone mesh
  54024. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54025. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54026. * * 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.
  54027. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54028. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54029. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54030. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54031. * * 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).
  54032. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54033. * * 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).
  54034. * * 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
  54035. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54036. * * 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
  54037. * * 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.
  54038. * * If `enclose` is false, a ring surface is one element.
  54039. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54040. * * 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
  54041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54042. * * 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
  54043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54044. * @param name defines the name of the mesh
  54045. * @param options defines the options used to create the mesh
  54046. * @param scene defines the hosting scene
  54047. * @returns the cylinder mesh
  54048. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54049. */
  54050. static CreateCylinder(name: string, options: {
  54051. height?: number;
  54052. diameterTop?: number;
  54053. diameterBottom?: number;
  54054. diameter?: number;
  54055. tessellation?: number;
  54056. subdivisions?: number;
  54057. arc?: number;
  54058. faceColors?: Color4[];
  54059. faceUV?: Vector4[];
  54060. updatable?: boolean;
  54061. hasRings?: boolean;
  54062. enclose?: boolean;
  54063. cap?: number;
  54064. sideOrientation?: number;
  54065. frontUVs?: Vector4;
  54066. backUVs?: Vector4;
  54067. }, scene?: Nullable<Scene>): Mesh;
  54068. /**
  54069. * Creates a torus mesh
  54070. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54071. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54072. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54074. * * 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
  54075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54076. * @param name defines the name of the mesh
  54077. * @param options defines the options used to create the mesh
  54078. * @param scene defines the hosting scene
  54079. * @returns the torus mesh
  54080. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54081. */
  54082. static CreateTorus(name: string, options: {
  54083. diameter?: number;
  54084. thickness?: number;
  54085. tessellation?: number;
  54086. updatable?: boolean;
  54087. sideOrientation?: number;
  54088. frontUVs?: Vector4;
  54089. backUVs?: Vector4;
  54090. }, scene?: Nullable<Scene>): Mesh;
  54091. /**
  54092. * Creates a torus knot mesh
  54093. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54094. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54095. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54096. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54098. * * 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
  54099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54100. * @param name defines the name of the mesh
  54101. * @param options defines the options used to create the mesh
  54102. * @param scene defines the hosting scene
  54103. * @returns the torus knot mesh
  54104. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54105. */
  54106. static CreateTorusKnot(name: string, options: {
  54107. radius?: number;
  54108. tube?: number;
  54109. radialSegments?: number;
  54110. tubularSegments?: number;
  54111. p?: number;
  54112. q?: number;
  54113. updatable?: boolean;
  54114. sideOrientation?: number;
  54115. frontUVs?: Vector4;
  54116. backUVs?: Vector4;
  54117. }, scene?: Nullable<Scene>): Mesh;
  54118. /**
  54119. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54120. * * 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
  54121. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54122. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54123. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54124. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54125. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54126. * * 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
  54127. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54130. * @param name defines the name of the new line system
  54131. * @param options defines the options used to create the line system
  54132. * @param scene defines the hosting scene
  54133. * @returns a new line system mesh
  54134. */
  54135. static CreateLineSystem(name: string, options: {
  54136. lines: Vector3[][];
  54137. updatable?: boolean;
  54138. instance?: Nullable<LinesMesh>;
  54139. colors?: Nullable<Color4[][]>;
  54140. useVertexAlpha?: boolean;
  54141. }, scene: Nullable<Scene>): LinesMesh;
  54142. /**
  54143. * Creates a line mesh
  54144. * 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
  54145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54146. * * The parameter `points` is an array successive Vector3
  54147. * * 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
  54148. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54149. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54150. * * When updating an instance, remember that only point positions can change, not the number of points
  54151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54153. * @param name defines the name of the new line system
  54154. * @param options defines the options used to create the line system
  54155. * @param scene defines the hosting scene
  54156. * @returns a new line mesh
  54157. */
  54158. static CreateLines(name: string, options: {
  54159. points: Vector3[];
  54160. updatable?: boolean;
  54161. instance?: Nullable<LinesMesh>;
  54162. colors?: Color4[];
  54163. useVertexAlpha?: boolean;
  54164. }, scene?: Nullable<Scene>): LinesMesh;
  54165. /**
  54166. * Creates a dashed line mesh
  54167. * * 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
  54168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54169. * * The parameter `points` is an array successive Vector3
  54170. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54171. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54172. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54173. * * 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
  54174. * * When updating an instance, remember that only point positions can change, not the number of points
  54175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54176. * @param name defines the name of the mesh
  54177. * @param options defines the options used to create the mesh
  54178. * @param scene defines the hosting scene
  54179. * @returns the dashed line mesh
  54180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54181. */
  54182. static CreateDashedLines(name: string, options: {
  54183. points: Vector3[];
  54184. dashSize?: number;
  54185. gapSize?: number;
  54186. dashNb?: number;
  54187. updatable?: boolean;
  54188. instance?: LinesMesh;
  54189. }, scene?: Nullable<Scene>): LinesMesh;
  54190. /**
  54191. * 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.
  54192. * * 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.
  54193. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54194. * * 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.
  54195. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54196. * * 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
  54197. * * 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
  54198. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54200. * * 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
  54201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54203. * @param name defines the name of the mesh
  54204. * @param options defines the options used to create the mesh
  54205. * @param scene defines the hosting scene
  54206. * @returns the extruded shape mesh
  54207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54209. */
  54210. static ExtrudeShape(name: string, options: {
  54211. shape: Vector3[];
  54212. path: Vector3[];
  54213. scale?: number;
  54214. rotation?: number;
  54215. cap?: number;
  54216. updatable?: boolean;
  54217. sideOrientation?: number;
  54218. frontUVs?: Vector4;
  54219. backUVs?: Vector4;
  54220. instance?: Mesh;
  54221. invertUV?: boolean;
  54222. }, scene?: Nullable<Scene>): Mesh;
  54223. /**
  54224. * Creates an custom extruded shape mesh.
  54225. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54226. * * 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.
  54227. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54228. * * 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
  54229. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54230. * * 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
  54231. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54232. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54233. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54234. * * 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
  54235. * * 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
  54236. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54238. * * 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
  54239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54241. * @param name defines the name of the mesh
  54242. * @param options defines the options used to create the mesh
  54243. * @param scene defines the hosting scene
  54244. * @returns the custom extruded shape mesh
  54245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54248. */
  54249. static ExtrudeShapeCustom(name: string, options: {
  54250. shape: Vector3[];
  54251. path: Vector3[];
  54252. scaleFunction?: any;
  54253. rotationFunction?: any;
  54254. ribbonCloseArray?: boolean;
  54255. ribbonClosePath?: boolean;
  54256. cap?: number;
  54257. updatable?: boolean;
  54258. sideOrientation?: number;
  54259. frontUVs?: Vector4;
  54260. backUVs?: Vector4;
  54261. instance?: Mesh;
  54262. invertUV?: boolean;
  54263. }, scene?: Nullable<Scene>): Mesh;
  54264. /**
  54265. * Creates lathe mesh.
  54266. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54267. * * 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
  54268. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54269. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54270. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54271. * * 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
  54272. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54273. * * 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
  54274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54275. * * 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
  54276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54278. * @param name defines the name of the mesh
  54279. * @param options defines the options used to create the mesh
  54280. * @param scene defines the hosting scene
  54281. * @returns the lathe mesh
  54282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54283. */
  54284. static CreateLathe(name: string, options: {
  54285. shape: Vector3[];
  54286. radius?: number;
  54287. tessellation?: number;
  54288. clip?: number;
  54289. arc?: number;
  54290. closed?: boolean;
  54291. updatable?: boolean;
  54292. sideOrientation?: number;
  54293. frontUVs?: Vector4;
  54294. backUVs?: Vector4;
  54295. cap?: number;
  54296. invertUV?: boolean;
  54297. }, scene?: Nullable<Scene>): Mesh;
  54298. /**
  54299. * Creates a tiled plane mesh
  54300. * * You can set a limited pattern arrangement with the tiles
  54301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54302. * * 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
  54303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54304. * @param name defines the name of the mesh
  54305. * @param options defines the options used to create the mesh
  54306. * @param scene defines the hosting scene
  54307. * @returns the plane mesh
  54308. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54309. */
  54310. static CreateTiledPlane(name: string, options: {
  54311. pattern?: number;
  54312. tileSize?: number;
  54313. tileWidth?: number;
  54314. tileHeight?: number;
  54315. size?: number;
  54316. width?: number;
  54317. height?: number;
  54318. alignHorizontal?: number;
  54319. alignVertical?: number;
  54320. sideOrientation?: number;
  54321. frontUVs?: Vector4;
  54322. backUVs?: Vector4;
  54323. updatable?: boolean;
  54324. }, scene?: Nullable<Scene>): Mesh;
  54325. /**
  54326. * Creates a plane mesh
  54327. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54328. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54329. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54331. * * 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
  54332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54333. * @param name defines the name of the mesh
  54334. * @param options defines the options used to create the mesh
  54335. * @param scene defines the hosting scene
  54336. * @returns the plane mesh
  54337. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54338. */
  54339. static CreatePlane(name: string, options: {
  54340. size?: number;
  54341. width?: number;
  54342. height?: number;
  54343. sideOrientation?: number;
  54344. frontUVs?: Vector4;
  54345. backUVs?: Vector4;
  54346. updatable?: boolean;
  54347. sourcePlane?: Plane;
  54348. }, scene?: Nullable<Scene>): Mesh;
  54349. /**
  54350. * Creates a ground mesh
  54351. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54352. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54354. * @param name defines the name of the mesh
  54355. * @param options defines the options used to create the mesh
  54356. * @param scene defines the hosting scene
  54357. * @returns the ground mesh
  54358. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54359. */
  54360. static CreateGround(name: string, options: {
  54361. width?: number;
  54362. height?: number;
  54363. subdivisions?: number;
  54364. subdivisionsX?: number;
  54365. subdivisionsY?: number;
  54366. updatable?: boolean;
  54367. }, scene?: Nullable<Scene>): Mesh;
  54368. /**
  54369. * Creates a tiled ground mesh
  54370. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54371. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54372. * * 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
  54373. * * 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
  54374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54375. * @param name defines the name of the mesh
  54376. * @param options defines the options used to create the mesh
  54377. * @param scene defines the hosting scene
  54378. * @returns the tiled ground mesh
  54379. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54380. */
  54381. static CreateTiledGround(name: string, options: {
  54382. xmin: number;
  54383. zmin: number;
  54384. xmax: number;
  54385. zmax: number;
  54386. subdivisions?: {
  54387. w: number;
  54388. h: number;
  54389. };
  54390. precision?: {
  54391. w: number;
  54392. h: number;
  54393. };
  54394. updatable?: boolean;
  54395. }, scene?: Nullable<Scene>): Mesh;
  54396. /**
  54397. * Creates a ground mesh from a height map
  54398. * * The parameter `url` sets the URL of the height map image resource.
  54399. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54400. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54401. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54402. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54403. * * 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.
  54404. * * 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).
  54405. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54407. * @param name defines the name of the mesh
  54408. * @param url defines the url to the height map
  54409. * @param options defines the options used to create the mesh
  54410. * @param scene defines the hosting scene
  54411. * @returns the ground mesh
  54412. * @see https://doc.babylonjs.com/babylon101/height_map
  54413. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54414. */
  54415. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54416. width?: number;
  54417. height?: number;
  54418. subdivisions?: number;
  54419. minHeight?: number;
  54420. maxHeight?: number;
  54421. colorFilter?: Color3;
  54422. alphaFilter?: number;
  54423. updatable?: boolean;
  54424. onReady?: (mesh: GroundMesh) => void;
  54425. }, scene?: Nullable<Scene>): GroundMesh;
  54426. /**
  54427. * Creates a polygon mesh
  54428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54429. * * 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
  54430. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54432. * * 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)
  54433. * * Remember you can only change the shape positions, not their number when updating a polygon
  54434. * @param name defines the name of the mesh
  54435. * @param options defines the options used to create the mesh
  54436. * @param scene defines the hosting scene
  54437. * @param earcutInjection can be used to inject your own earcut reference
  54438. * @returns the polygon mesh
  54439. */
  54440. static CreatePolygon(name: string, options: {
  54441. shape: Vector3[];
  54442. holes?: Vector3[][];
  54443. depth?: number;
  54444. faceUV?: Vector4[];
  54445. faceColors?: Color4[];
  54446. updatable?: boolean;
  54447. sideOrientation?: number;
  54448. frontUVs?: Vector4;
  54449. backUVs?: Vector4;
  54450. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54451. /**
  54452. * Creates an extruded polygon mesh, with depth in the Y direction.
  54453. * * 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)
  54454. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54455. * @param name defines the name of the mesh
  54456. * @param options defines the options used to create the mesh
  54457. * @param scene defines the hosting scene
  54458. * @param earcutInjection can be used to inject your own earcut reference
  54459. * @returns the polygon mesh
  54460. */
  54461. static ExtrudePolygon(name: string, options: {
  54462. shape: Vector3[];
  54463. holes?: Vector3[][];
  54464. depth?: number;
  54465. faceUV?: Vector4[];
  54466. faceColors?: Color4[];
  54467. updatable?: boolean;
  54468. sideOrientation?: number;
  54469. frontUVs?: Vector4;
  54470. backUVs?: Vector4;
  54471. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54472. /**
  54473. * Creates a tube mesh.
  54474. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54475. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54476. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54477. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54478. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54479. * * 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)
  54480. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54481. * * 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
  54482. * * 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
  54483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54484. * * 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
  54485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54487. * @param name defines the name of the mesh
  54488. * @param options defines the options used to create the mesh
  54489. * @param scene defines the hosting scene
  54490. * @returns the tube mesh
  54491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54492. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54493. */
  54494. static CreateTube(name: string, options: {
  54495. path: Vector3[];
  54496. radius?: number;
  54497. tessellation?: number;
  54498. radiusFunction?: {
  54499. (i: number, distance: number): number;
  54500. };
  54501. cap?: number;
  54502. arc?: number;
  54503. updatable?: boolean;
  54504. sideOrientation?: number;
  54505. frontUVs?: Vector4;
  54506. backUVs?: Vector4;
  54507. instance?: Mesh;
  54508. invertUV?: boolean;
  54509. }, scene?: Nullable<Scene>): Mesh;
  54510. /**
  54511. * Creates a polyhedron mesh
  54512. * * 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
  54513. * * The parameter `size` (positive float, default 1) sets the polygon size
  54514. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54515. * * 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`
  54516. * * 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
  54517. * * 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)`)
  54518. * * 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
  54519. * * 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
  54520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54521. * * 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
  54522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54523. * @param name defines the name of the mesh
  54524. * @param options defines the options used to create the mesh
  54525. * @param scene defines the hosting scene
  54526. * @returns the polyhedron mesh
  54527. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54528. */
  54529. static CreatePolyhedron(name: string, options: {
  54530. type?: number;
  54531. size?: number;
  54532. sizeX?: number;
  54533. sizeY?: number;
  54534. sizeZ?: number;
  54535. custom?: any;
  54536. faceUV?: Vector4[];
  54537. faceColors?: Color4[];
  54538. flat?: boolean;
  54539. updatable?: boolean;
  54540. sideOrientation?: number;
  54541. frontUVs?: Vector4;
  54542. backUVs?: Vector4;
  54543. }, scene?: Nullable<Scene>): Mesh;
  54544. /**
  54545. * Creates a decal mesh.
  54546. * 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
  54547. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54548. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54549. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54550. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54551. * @param name defines the name of the mesh
  54552. * @param sourceMesh defines the mesh where the decal must be applied
  54553. * @param options defines the options used to create the mesh
  54554. * @param scene defines the hosting scene
  54555. * @returns the decal mesh
  54556. * @see https://doc.babylonjs.com/how_to/decals
  54557. */
  54558. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54559. position?: Vector3;
  54560. normal?: Vector3;
  54561. size?: Vector3;
  54562. angle?: number;
  54563. }): Mesh;
  54564. }
  54565. }
  54566. declare module BABYLON {
  54567. /**
  54568. * A simplifier interface for future simplification implementations
  54569. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54570. */
  54571. export interface ISimplifier {
  54572. /**
  54573. * Simplification of a given mesh according to the given settings.
  54574. * Since this requires computation, it is assumed that the function runs async.
  54575. * @param settings The settings of the simplification, including quality and distance
  54576. * @param successCallback A callback that will be called after the mesh was simplified.
  54577. * @param errorCallback in case of an error, this callback will be called. optional.
  54578. */
  54579. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54580. }
  54581. /**
  54582. * Expected simplification settings.
  54583. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54584. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54585. */
  54586. export interface ISimplificationSettings {
  54587. /**
  54588. * Gets or sets the expected quality
  54589. */
  54590. quality: number;
  54591. /**
  54592. * Gets or sets the distance when this optimized version should be used
  54593. */
  54594. distance: number;
  54595. /**
  54596. * Gets an already optimized mesh
  54597. */
  54598. optimizeMesh?: boolean;
  54599. }
  54600. /**
  54601. * Class used to specify simplification options
  54602. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54603. */
  54604. export class SimplificationSettings implements ISimplificationSettings {
  54605. /** expected quality */
  54606. quality: number;
  54607. /** distance when this optimized version should be used */
  54608. distance: number;
  54609. /** already optimized mesh */
  54610. optimizeMesh?: boolean | undefined;
  54611. /**
  54612. * Creates a SimplificationSettings
  54613. * @param quality expected quality
  54614. * @param distance distance when this optimized version should be used
  54615. * @param optimizeMesh already optimized mesh
  54616. */
  54617. constructor(
  54618. /** expected quality */
  54619. quality: number,
  54620. /** distance when this optimized version should be used */
  54621. distance: number,
  54622. /** already optimized mesh */
  54623. optimizeMesh?: boolean | undefined);
  54624. }
  54625. /**
  54626. * Interface used to define a simplification task
  54627. */
  54628. export interface ISimplificationTask {
  54629. /**
  54630. * Array of settings
  54631. */
  54632. settings: Array<ISimplificationSettings>;
  54633. /**
  54634. * Simplification type
  54635. */
  54636. simplificationType: SimplificationType;
  54637. /**
  54638. * Mesh to simplify
  54639. */
  54640. mesh: Mesh;
  54641. /**
  54642. * Callback called on success
  54643. */
  54644. successCallback?: () => void;
  54645. /**
  54646. * Defines if parallel processing can be used
  54647. */
  54648. parallelProcessing: boolean;
  54649. }
  54650. /**
  54651. * Queue used to order the simplification tasks
  54652. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54653. */
  54654. export class SimplificationQueue {
  54655. private _simplificationArray;
  54656. /**
  54657. * Gets a boolean indicating that the process is still running
  54658. */
  54659. running: boolean;
  54660. /**
  54661. * Creates a new queue
  54662. */
  54663. constructor();
  54664. /**
  54665. * Adds a new simplification task
  54666. * @param task defines a task to add
  54667. */
  54668. addTask(task: ISimplificationTask): void;
  54669. /**
  54670. * Execute next task
  54671. */
  54672. executeNext(): void;
  54673. /**
  54674. * Execute a simplification task
  54675. * @param task defines the task to run
  54676. */
  54677. runSimplification(task: ISimplificationTask): void;
  54678. private getSimplifier;
  54679. }
  54680. /**
  54681. * The implemented types of simplification
  54682. * At the moment only Quadratic Error Decimation is implemented
  54683. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54684. */
  54685. export enum SimplificationType {
  54686. /** Quadratic error decimation */
  54687. QUADRATIC = 0
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. interface Scene {
  54692. /** @hidden (Backing field) */
  54693. _simplificationQueue: SimplificationQueue;
  54694. /**
  54695. * Gets or sets the simplification queue attached to the scene
  54696. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54697. */
  54698. simplificationQueue: SimplificationQueue;
  54699. }
  54700. interface Mesh {
  54701. /**
  54702. * Simplify the mesh according to the given array of settings.
  54703. * Function will return immediately and will simplify async
  54704. * @param settings a collection of simplification settings
  54705. * @param parallelProcessing should all levels calculate parallel or one after the other
  54706. * @param simplificationType the type of simplification to run
  54707. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54708. * @returns the current mesh
  54709. */
  54710. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54711. }
  54712. /**
  54713. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54714. * created in a scene
  54715. */
  54716. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54717. /**
  54718. * The component name helpfull to identify the component in the list of scene components.
  54719. */
  54720. readonly name: string;
  54721. /**
  54722. * The scene the component belongs to.
  54723. */
  54724. scene: Scene;
  54725. /**
  54726. * Creates a new instance of the component for the given scene
  54727. * @param scene Defines the scene to register the component in
  54728. */
  54729. constructor(scene: Scene);
  54730. /**
  54731. * Registers the component in a given scene
  54732. */
  54733. register(): void;
  54734. /**
  54735. * Rebuilds the elements related to this component in case of
  54736. * context lost for instance.
  54737. */
  54738. rebuild(): void;
  54739. /**
  54740. * Disposes the component and the associated ressources
  54741. */
  54742. dispose(): void;
  54743. private _beforeCameraUpdate;
  54744. }
  54745. }
  54746. declare module BABYLON {
  54747. /**
  54748. * Navigation plugin interface to add navigation constrained by a navigation mesh
  54749. */
  54750. export interface INavigationEnginePlugin {
  54751. /**
  54752. * plugin name
  54753. */
  54754. name: string;
  54755. /**
  54756. * Creates a navigation mesh
  54757. * @param meshes array of all the geometry used to compute the navigatio mesh
  54758. * @param parameters bunch of parameters used to filter geometry
  54759. */
  54760. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54761. /**
  54762. * Create a navigation mesh debug mesh
  54763. * @param scene is where the mesh will be added
  54764. * @returns debug display mesh
  54765. */
  54766. createDebugNavMesh(scene: Scene): Mesh;
  54767. /**
  54768. * Get a navigation mesh constrained position, closest to the parameter position
  54769. * @param position world position
  54770. * @returns the closest point to position constrained by the navigation mesh
  54771. */
  54772. getClosestPoint(position: Vector3): Vector3;
  54773. /**
  54774. * Get a navigation mesh constrained position, within a particular radius
  54775. * @param position world position
  54776. * @param maxRadius the maximum distance to the constrained world position
  54777. * @returns the closest point to position constrained by the navigation mesh
  54778. */
  54779. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54780. /**
  54781. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54782. * @param start world position
  54783. * @param end world position
  54784. * @returns array containing world position composing the path
  54785. */
  54786. computePath(start: Vector3, end: Vector3): Vector3[];
  54787. /**
  54788. * If this plugin is supported
  54789. * @returns true if plugin is supported
  54790. */
  54791. isSupported(): boolean;
  54792. /**
  54793. * Create a new Crowd so you can add agents
  54794. * @param maxAgents the maximum agent count in the crowd
  54795. * @param maxAgentRadius the maximum radius an agent can have
  54796. * @param scene to attach the crowd to
  54797. * @returns the crowd you can add agents to
  54798. */
  54799. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54800. /**
  54801. * Release all resources
  54802. */
  54803. dispose(): void;
  54804. }
  54805. /**
  54806. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54807. */
  54808. export interface ICrowd {
  54809. /**
  54810. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54811. * You can attach anything to that node. The node position is updated in the scene update tick.
  54812. * @param pos world position that will be constrained by the navigation mesh
  54813. * @param parameters agent parameters
  54814. * @param transform hooked to the agent that will be update by the scene
  54815. * @returns agent index
  54816. */
  54817. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54818. /**
  54819. * Returns the agent position in world space
  54820. * @param index agent index returned by addAgent
  54821. * @returns world space position
  54822. */
  54823. getAgentPosition(index: number): Vector3;
  54824. /**
  54825. * Gets the agent velocity in world space
  54826. * @param index agent index returned by addAgent
  54827. * @returns world space velocity
  54828. */
  54829. getAgentVelocity(index: number): Vector3;
  54830. /**
  54831. * remove a particular agent previously created
  54832. * @param index agent index returned by addAgent
  54833. */
  54834. removeAgent(index: number): void;
  54835. /**
  54836. * get the list of all agents attached to this crowd
  54837. * @returns list of agent indices
  54838. */
  54839. getAgents(): number[];
  54840. /**
  54841. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54842. * @param deltaTime in seconds
  54843. */
  54844. update(deltaTime: number): void;
  54845. /**
  54846. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54847. * @param index agent index returned by addAgent
  54848. * @param destination targeted world position
  54849. */
  54850. agentGoto(index: number, destination: Vector3): void;
  54851. /**
  54852. * Release all resources
  54853. */
  54854. dispose(): void;
  54855. }
  54856. /**
  54857. * Configures an agent
  54858. */
  54859. export interface IAgentParameters {
  54860. /**
  54861. * Agent radius. [Limit: >= 0]
  54862. */
  54863. radius: number;
  54864. /**
  54865. * Agent height. [Limit: > 0]
  54866. */
  54867. height: number;
  54868. /**
  54869. * Maximum allowed acceleration. [Limit: >= 0]
  54870. */
  54871. maxAcceleration: number;
  54872. /**
  54873. * Maximum allowed speed. [Limit: >= 0]
  54874. */
  54875. maxSpeed: number;
  54876. /**
  54877. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54878. */
  54879. collisionQueryRange: number;
  54880. /**
  54881. * The path visibility optimization range. [Limit: > 0]
  54882. */
  54883. pathOptimizationRange: number;
  54884. /**
  54885. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54886. */
  54887. separationWeight: number;
  54888. }
  54889. /**
  54890. * Configures the navigation mesh creation
  54891. */
  54892. export interface INavMeshParameters {
  54893. /**
  54894. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54895. */
  54896. cs: number;
  54897. /**
  54898. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54899. */
  54900. ch: number;
  54901. /**
  54902. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54903. */
  54904. walkableSlopeAngle: number;
  54905. /**
  54906. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54907. * be considered walkable. [Limit: >= 3] [Units: vx]
  54908. */
  54909. walkableHeight: number;
  54910. /**
  54911. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54912. */
  54913. walkableClimb: number;
  54914. /**
  54915. * The distance to erode/shrink the walkable area of the heightfield away from
  54916. * obstructions. [Limit: >=0] [Units: vx]
  54917. */
  54918. walkableRadius: number;
  54919. /**
  54920. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54921. */
  54922. maxEdgeLen: number;
  54923. /**
  54924. * The maximum distance a simplfied contour's border edges should deviate
  54925. * the original raw contour. [Limit: >=0] [Units: vx]
  54926. */
  54927. maxSimplificationError: number;
  54928. /**
  54929. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54930. */
  54931. minRegionArea: number;
  54932. /**
  54933. * Any regions with a span count smaller than this value will, if possible,
  54934. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54935. */
  54936. mergeRegionArea: number;
  54937. /**
  54938. * The maximum number of vertices allowed for polygons generated during the
  54939. * contour to polygon conversion process. [Limit: >= 3]
  54940. */
  54941. maxVertsPerPoly: number;
  54942. /**
  54943. * Sets the sampling distance to use when generating the detail mesh.
  54944. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54945. */
  54946. detailSampleDist: number;
  54947. /**
  54948. * The maximum distance the detail mesh surface should deviate from heightfield
  54949. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54950. */
  54951. detailSampleMaxError: number;
  54952. }
  54953. }
  54954. declare module BABYLON {
  54955. /**
  54956. * RecastJS navigation plugin
  54957. */
  54958. export class RecastJSPlugin implements INavigationEnginePlugin {
  54959. /**
  54960. * Reference to the Recast library
  54961. */
  54962. bjsRECAST: any;
  54963. /**
  54964. * plugin name
  54965. */
  54966. name: string;
  54967. /**
  54968. * the first navmesh created. We might extend this to support multiple navmeshes
  54969. */
  54970. navMesh: any;
  54971. /**
  54972. * Initializes the recastJS plugin
  54973. * @param recastInjection can be used to inject your own recast reference
  54974. */
  54975. constructor(recastInjection?: any);
  54976. /**
  54977. * Creates a navigation mesh
  54978. * @param meshes array of all the geometry used to compute the navigatio mesh
  54979. * @param parameters bunch of parameters used to filter geometry
  54980. */
  54981. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54982. /**
  54983. * Create a navigation mesh debug mesh
  54984. * @param scene is where the mesh will be added
  54985. * @returns debug display mesh
  54986. */
  54987. createDebugNavMesh(scene: Scene): Mesh;
  54988. /**
  54989. * Get a navigation mesh constrained position, closest to the parameter position
  54990. * @param position world position
  54991. * @returns the closest point to position constrained by the navigation mesh
  54992. */
  54993. getClosestPoint(position: Vector3): Vector3;
  54994. /**
  54995. * Get a navigation mesh constrained position, within a particular radius
  54996. * @param position world position
  54997. * @param maxRadius the maximum distance to the constrained world position
  54998. * @returns the closest point to position constrained by the navigation mesh
  54999. */
  55000. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55001. /**
  55002. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55003. * @param start world position
  55004. * @param end world position
  55005. * @returns array containing world position composing the path
  55006. */
  55007. computePath(start: Vector3, end: Vector3): Vector3[];
  55008. /**
  55009. * Create a new Crowd so you can add agents
  55010. * @param maxAgents the maximum agent count in the crowd
  55011. * @param maxAgentRadius the maximum radius an agent can have
  55012. * @param scene to attach the crowd to
  55013. * @returns the crowd you can add agents to
  55014. */
  55015. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55016. /**
  55017. * Disposes
  55018. */
  55019. dispose(): void;
  55020. /**
  55021. * If this plugin is supported
  55022. * @returns true if plugin is supported
  55023. */
  55024. isSupported(): boolean;
  55025. }
  55026. /**
  55027. * Recast detour crowd implementation
  55028. */
  55029. export class RecastJSCrowd implements ICrowd {
  55030. /**
  55031. * Recast/detour plugin
  55032. */
  55033. bjsRECASTPlugin: RecastJSPlugin;
  55034. /**
  55035. * Link to the detour crowd
  55036. */
  55037. recastCrowd: any;
  55038. /**
  55039. * One transform per agent
  55040. */
  55041. transforms: TransformNode[];
  55042. /**
  55043. * All agents created
  55044. */
  55045. agents: number[];
  55046. /**
  55047. * Link to the scene is kept to unregister the crowd from the scene
  55048. */
  55049. private _scene;
  55050. /**
  55051. * Observer for crowd updates
  55052. */
  55053. private _onBeforeAnimationsObserver;
  55054. /**
  55055. * Constructor
  55056. * @param plugin recastJS plugin
  55057. * @param maxAgents the maximum agent count in the crowd
  55058. * @param maxAgentRadius the maximum radius an agent can have
  55059. * @param scene to attach the crowd to
  55060. * @returns the crowd you can add agents to
  55061. */
  55062. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55063. /**
  55064. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55065. * You can attach anything to that node. The node position is updated in the scene update tick.
  55066. * @param pos world position that will be constrained by the navigation mesh
  55067. * @param parameters agent parameters
  55068. * @param transform hooked to the agent that will be update by the scene
  55069. * @returns agent index
  55070. */
  55071. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55072. /**
  55073. * Returns the agent position in world space
  55074. * @param index agent index returned by addAgent
  55075. * @returns world space position
  55076. */
  55077. getAgentPosition(index: number): Vector3;
  55078. /**
  55079. * Returns the agent velocity in world space
  55080. * @param index agent index returned by addAgent
  55081. * @returns world space velocity
  55082. */
  55083. getAgentVelocity(index: number): Vector3;
  55084. /**
  55085. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55086. * @param index agent index returned by addAgent
  55087. * @param destination targeted world position
  55088. */
  55089. agentGoto(index: number, destination: Vector3): void;
  55090. /**
  55091. * remove a particular agent previously created
  55092. * @param index agent index returned by addAgent
  55093. */
  55094. removeAgent(index: number): void;
  55095. /**
  55096. * get the list of all agents attached to this crowd
  55097. * @returns list of agent indices
  55098. */
  55099. getAgents(): number[];
  55100. /**
  55101. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55102. * @param deltaTime in seconds
  55103. */
  55104. update(deltaTime: number): void;
  55105. /**
  55106. * Release all resources
  55107. */
  55108. dispose(): void;
  55109. }
  55110. }
  55111. declare module BABYLON {
  55112. /**
  55113. * Class used to enable access to IndexedDB
  55114. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55115. */
  55116. export class Database implements IOfflineProvider {
  55117. private _callbackManifestChecked;
  55118. private _currentSceneUrl;
  55119. private _db;
  55120. private _enableSceneOffline;
  55121. private _enableTexturesOffline;
  55122. private _manifestVersionFound;
  55123. private _mustUpdateRessources;
  55124. private _hasReachedQuota;
  55125. private _isSupported;
  55126. private _idbFactory;
  55127. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55128. private static IsUASupportingBlobStorage;
  55129. /**
  55130. * Gets a boolean indicating if Database storate is enabled (off by default)
  55131. */
  55132. static IDBStorageEnabled: boolean;
  55133. /**
  55134. * Gets a boolean indicating if scene must be saved in the database
  55135. */
  55136. readonly enableSceneOffline: boolean;
  55137. /**
  55138. * Gets a boolean indicating if textures must be saved in the database
  55139. */
  55140. readonly enableTexturesOffline: boolean;
  55141. /**
  55142. * Creates a new Database
  55143. * @param urlToScene defines the url to load the scene
  55144. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55145. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55146. */
  55147. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55148. private static _ParseURL;
  55149. private static _ReturnFullUrlLocation;
  55150. private _checkManifestFile;
  55151. /**
  55152. * Open the database and make it available
  55153. * @param successCallback defines the callback to call on success
  55154. * @param errorCallback defines the callback to call on error
  55155. */
  55156. open(successCallback: () => void, errorCallback: () => void): void;
  55157. /**
  55158. * Loads an image from the database
  55159. * @param url defines the url to load from
  55160. * @param image defines the target DOM image
  55161. */
  55162. loadImage(url: string, image: HTMLImageElement): void;
  55163. private _loadImageFromDBAsync;
  55164. private _saveImageIntoDBAsync;
  55165. private _checkVersionFromDB;
  55166. private _loadVersionFromDBAsync;
  55167. private _saveVersionIntoDBAsync;
  55168. /**
  55169. * Loads a file from database
  55170. * @param url defines the URL to load from
  55171. * @param sceneLoaded defines a callback to call on success
  55172. * @param progressCallBack defines a callback to call when progress changed
  55173. * @param errorCallback defines a callback to call on error
  55174. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55175. */
  55176. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55177. private _loadFileAsync;
  55178. private _saveFileAsync;
  55179. /**
  55180. * Validates if xhr data is correct
  55181. * @param xhr defines the request to validate
  55182. * @param dataType defines the expected data type
  55183. * @returns true if data is correct
  55184. */
  55185. private static _ValidateXHRData;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /** @hidden */
  55190. export var gpuUpdateParticlesPixelShader: {
  55191. name: string;
  55192. shader: string;
  55193. };
  55194. }
  55195. declare module BABYLON {
  55196. /** @hidden */
  55197. export var gpuUpdateParticlesVertexShader: {
  55198. name: string;
  55199. shader: string;
  55200. };
  55201. }
  55202. declare module BABYLON {
  55203. /** @hidden */
  55204. export var clipPlaneFragmentDeclaration2: {
  55205. name: string;
  55206. shader: string;
  55207. };
  55208. }
  55209. declare module BABYLON {
  55210. /** @hidden */
  55211. export var gpuRenderParticlesPixelShader: {
  55212. name: string;
  55213. shader: string;
  55214. };
  55215. }
  55216. declare module BABYLON {
  55217. /** @hidden */
  55218. export var clipPlaneVertexDeclaration2: {
  55219. name: string;
  55220. shader: string;
  55221. };
  55222. }
  55223. declare module BABYLON {
  55224. /** @hidden */
  55225. export var gpuRenderParticlesVertexShader: {
  55226. name: string;
  55227. shader: string;
  55228. };
  55229. }
  55230. declare module BABYLON {
  55231. /**
  55232. * This represents a GPU particle system in Babylon
  55233. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55234. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55235. */
  55236. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55237. /**
  55238. * The layer mask we are rendering the particles through.
  55239. */
  55240. layerMask: number;
  55241. private _capacity;
  55242. private _activeCount;
  55243. private _currentActiveCount;
  55244. private _accumulatedCount;
  55245. private _renderEffect;
  55246. private _updateEffect;
  55247. private _buffer0;
  55248. private _buffer1;
  55249. private _spriteBuffer;
  55250. private _updateVAO;
  55251. private _renderVAO;
  55252. private _targetIndex;
  55253. private _sourceBuffer;
  55254. private _targetBuffer;
  55255. private _engine;
  55256. private _currentRenderId;
  55257. private _started;
  55258. private _stopped;
  55259. private _timeDelta;
  55260. private _randomTexture;
  55261. private _randomTexture2;
  55262. private _attributesStrideSize;
  55263. private _updateEffectOptions;
  55264. private _randomTextureSize;
  55265. private _actualFrame;
  55266. private readonly _rawTextureWidth;
  55267. /**
  55268. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55269. */
  55270. static readonly IsSupported: boolean;
  55271. /**
  55272. * An event triggered when the system is disposed.
  55273. */
  55274. onDisposeObservable: Observable<GPUParticleSystem>;
  55275. /**
  55276. * Gets the maximum number of particles active at the same time.
  55277. * @returns The max number of active particles.
  55278. */
  55279. getCapacity(): number;
  55280. /**
  55281. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55282. * to override the particles.
  55283. */
  55284. forceDepthWrite: boolean;
  55285. /**
  55286. * Gets or set the number of active particles
  55287. */
  55288. activeParticleCount: number;
  55289. private _preWarmDone;
  55290. /**
  55291. * Is this system ready to be used/rendered
  55292. * @return true if the system is ready
  55293. */
  55294. isReady(): boolean;
  55295. /**
  55296. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55297. * @returns True if it has been started, otherwise false.
  55298. */
  55299. isStarted(): boolean;
  55300. /**
  55301. * Starts the particle system and begins to emit
  55302. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55303. */
  55304. start(delay?: number): void;
  55305. /**
  55306. * Stops the particle system.
  55307. */
  55308. stop(): void;
  55309. /**
  55310. * Remove all active particles
  55311. */
  55312. reset(): void;
  55313. /**
  55314. * Returns the string "GPUParticleSystem"
  55315. * @returns a string containing the class name
  55316. */
  55317. getClassName(): string;
  55318. private _colorGradientsTexture;
  55319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55320. /**
  55321. * Adds a new color gradient
  55322. * @param gradient defines the gradient to use (between 0 and 1)
  55323. * @param color1 defines the color to affect to the specified gradient
  55324. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55325. * @returns the current particle system
  55326. */
  55327. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55328. /**
  55329. * Remove a specific color gradient
  55330. * @param gradient defines the gradient to remove
  55331. * @returns the current particle system
  55332. */
  55333. removeColorGradient(gradient: number): GPUParticleSystem;
  55334. private _angularSpeedGradientsTexture;
  55335. private _sizeGradientsTexture;
  55336. private _velocityGradientsTexture;
  55337. private _limitVelocityGradientsTexture;
  55338. private _dragGradientsTexture;
  55339. private _addFactorGradient;
  55340. /**
  55341. * Adds a new size gradient
  55342. * @param gradient defines the gradient to use (between 0 and 1)
  55343. * @param factor defines the size factor to affect to the specified gradient
  55344. * @returns the current particle system
  55345. */
  55346. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55347. /**
  55348. * Remove a specific size gradient
  55349. * @param gradient defines the gradient to remove
  55350. * @returns the current particle system
  55351. */
  55352. removeSizeGradient(gradient: number): GPUParticleSystem;
  55353. /**
  55354. * Adds a new angular speed gradient
  55355. * @param gradient defines the gradient to use (between 0 and 1)
  55356. * @param factor defines the angular speed to affect to the specified gradient
  55357. * @returns the current particle system
  55358. */
  55359. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55360. /**
  55361. * Remove a specific angular speed gradient
  55362. * @param gradient defines the gradient to remove
  55363. * @returns the current particle system
  55364. */
  55365. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55366. /**
  55367. * Adds a new velocity gradient
  55368. * @param gradient defines the gradient to use (between 0 and 1)
  55369. * @param factor defines the velocity to affect to the specified gradient
  55370. * @returns the current particle system
  55371. */
  55372. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55373. /**
  55374. * Remove a specific velocity gradient
  55375. * @param gradient defines the gradient to remove
  55376. * @returns the current particle system
  55377. */
  55378. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55379. /**
  55380. * Adds a new limit velocity gradient
  55381. * @param gradient defines the gradient to use (between 0 and 1)
  55382. * @param factor defines the limit velocity value to affect to the specified gradient
  55383. * @returns the current particle system
  55384. */
  55385. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55386. /**
  55387. * Remove a specific limit velocity gradient
  55388. * @param gradient defines the gradient to remove
  55389. * @returns the current particle system
  55390. */
  55391. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55392. /**
  55393. * Adds a new drag gradient
  55394. * @param gradient defines the gradient to use (between 0 and 1)
  55395. * @param factor defines the drag value to affect to the specified gradient
  55396. * @returns the current particle system
  55397. */
  55398. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55399. /**
  55400. * Remove a specific drag gradient
  55401. * @param gradient defines the gradient to remove
  55402. * @returns the current particle system
  55403. */
  55404. removeDragGradient(gradient: number): GPUParticleSystem;
  55405. /**
  55406. * Not supported by GPUParticleSystem
  55407. * @param gradient defines the gradient to use (between 0 and 1)
  55408. * @param factor defines the emit rate value to affect to the specified gradient
  55409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55410. * @returns the current particle system
  55411. */
  55412. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55413. /**
  55414. * Not supported by GPUParticleSystem
  55415. * @param gradient defines the gradient to remove
  55416. * @returns the current particle system
  55417. */
  55418. removeEmitRateGradient(gradient: number): IParticleSystem;
  55419. /**
  55420. * Not supported by GPUParticleSystem
  55421. * @param gradient defines the gradient to use (between 0 and 1)
  55422. * @param factor defines the start size value to affect to the specified gradient
  55423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55424. * @returns the current particle system
  55425. */
  55426. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55427. /**
  55428. * Not supported by GPUParticleSystem
  55429. * @param gradient defines the gradient to remove
  55430. * @returns the current particle system
  55431. */
  55432. removeStartSizeGradient(gradient: number): IParticleSystem;
  55433. /**
  55434. * Not supported by GPUParticleSystem
  55435. * @param gradient defines the gradient to use (between 0 and 1)
  55436. * @param min defines the color remap minimal range
  55437. * @param max defines the color remap maximal range
  55438. * @returns the current particle system
  55439. */
  55440. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55441. /**
  55442. * Not supported by GPUParticleSystem
  55443. * @param gradient defines the gradient to remove
  55444. * @returns the current particle system
  55445. */
  55446. removeColorRemapGradient(): IParticleSystem;
  55447. /**
  55448. * Not supported by GPUParticleSystem
  55449. * @param gradient defines the gradient to use (between 0 and 1)
  55450. * @param min defines the alpha remap minimal range
  55451. * @param max defines the alpha remap maximal range
  55452. * @returns the current particle system
  55453. */
  55454. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55455. /**
  55456. * Not supported by GPUParticleSystem
  55457. * @param gradient defines the gradient to remove
  55458. * @returns the current particle system
  55459. */
  55460. removeAlphaRemapGradient(): IParticleSystem;
  55461. /**
  55462. * Not supported by GPUParticleSystem
  55463. * @param gradient defines the gradient to use (between 0 and 1)
  55464. * @param color defines the color to affect to the specified gradient
  55465. * @returns the current particle system
  55466. */
  55467. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55468. /**
  55469. * Not supported by GPUParticleSystem
  55470. * @param gradient defines the gradient to remove
  55471. * @returns the current particle system
  55472. */
  55473. removeRampGradient(): IParticleSystem;
  55474. /**
  55475. * Not supported by GPUParticleSystem
  55476. * @returns the list of ramp gradients
  55477. */
  55478. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55479. /**
  55480. * Not supported by GPUParticleSystem
  55481. * Gets or sets a boolean indicating that ramp gradients must be used
  55482. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55483. */
  55484. useRampGradients: boolean;
  55485. /**
  55486. * Not supported by GPUParticleSystem
  55487. * @param gradient defines the gradient to use (between 0 and 1)
  55488. * @param factor defines the life time factor to affect to the specified gradient
  55489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55490. * @returns the current particle system
  55491. */
  55492. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55493. /**
  55494. * Not supported by GPUParticleSystem
  55495. * @param gradient defines the gradient to remove
  55496. * @returns the current particle system
  55497. */
  55498. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55499. /**
  55500. * Instantiates a GPU particle system.
  55501. * 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.
  55502. * @param name The name of the particle system
  55503. * @param options The options used to create the system
  55504. * @param scene The scene the particle system belongs to
  55505. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55506. */
  55507. constructor(name: string, options: Partial<{
  55508. capacity: number;
  55509. randomTextureSize: number;
  55510. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55511. protected _reset(): void;
  55512. private _createUpdateVAO;
  55513. private _createRenderVAO;
  55514. private _initialize;
  55515. /** @hidden */
  55516. _recreateUpdateEffect(): void;
  55517. /** @hidden */
  55518. _recreateRenderEffect(): void;
  55519. /**
  55520. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55521. * @param preWarm defines if we are in the pre-warmimg phase
  55522. */
  55523. animate(preWarm?: boolean): void;
  55524. private _createFactorGradientTexture;
  55525. private _createSizeGradientTexture;
  55526. private _createAngularSpeedGradientTexture;
  55527. private _createVelocityGradientTexture;
  55528. private _createLimitVelocityGradientTexture;
  55529. private _createDragGradientTexture;
  55530. private _createColorGradientTexture;
  55531. /**
  55532. * Renders the particle system in its current state
  55533. * @param preWarm defines if the system should only update the particles but not render them
  55534. * @returns the current number of particles
  55535. */
  55536. render(preWarm?: boolean): number;
  55537. /**
  55538. * Rebuilds the particle system
  55539. */
  55540. rebuild(): void;
  55541. private _releaseBuffers;
  55542. private _releaseVAOs;
  55543. /**
  55544. * Disposes the particle system and free the associated resources
  55545. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55546. */
  55547. dispose(disposeTexture?: boolean): void;
  55548. /**
  55549. * Clones the particle system.
  55550. * @param name The name of the cloned object
  55551. * @param newEmitter The new emitter to use
  55552. * @returns the cloned particle system
  55553. */
  55554. clone(name: string, newEmitter: any): GPUParticleSystem;
  55555. /**
  55556. * Serializes the particle system to a JSON object.
  55557. * @returns the JSON object
  55558. */
  55559. serialize(): any;
  55560. /**
  55561. * Parses a JSON object to create a GPU particle system.
  55562. * @param parsedParticleSystem The JSON object to parse
  55563. * @param scene The scene to create the particle system in
  55564. * @param rootUrl The root url to use to load external dependencies like texture
  55565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55566. * @returns the parsed GPU particle system
  55567. */
  55568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55569. }
  55570. }
  55571. declare module BABYLON {
  55572. /**
  55573. * Represents a set of particle systems working together to create a specific effect
  55574. */
  55575. export class ParticleSystemSet implements IDisposable {
  55576. private _emitterCreationOptions;
  55577. private _emitterNode;
  55578. /**
  55579. * Gets the particle system list
  55580. */
  55581. systems: IParticleSystem[];
  55582. /**
  55583. * Gets the emitter node used with this set
  55584. */
  55585. readonly emitterNode: Nullable<TransformNode>;
  55586. /**
  55587. * Creates a new emitter mesh as a sphere
  55588. * @param options defines the options used to create the sphere
  55589. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55590. * @param scene defines the hosting scene
  55591. */
  55592. setEmitterAsSphere(options: {
  55593. diameter: number;
  55594. segments: number;
  55595. color: Color3;
  55596. }, renderingGroupId: number, scene: Scene): void;
  55597. /**
  55598. * Starts all particle systems of the set
  55599. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55600. */
  55601. start(emitter?: AbstractMesh): void;
  55602. /**
  55603. * Release all associated resources
  55604. */
  55605. dispose(): void;
  55606. /**
  55607. * Serialize the set into a JSON compatible object
  55608. * @returns a JSON compatible representation of the set
  55609. */
  55610. serialize(): any;
  55611. /**
  55612. * Parse a new ParticleSystemSet from a serialized source
  55613. * @param data defines a JSON compatible representation of the set
  55614. * @param scene defines the hosting scene
  55615. * @param gpu defines if we want GPU particles or CPU particles
  55616. * @returns a new ParticleSystemSet
  55617. */
  55618. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55619. }
  55620. }
  55621. declare module BABYLON {
  55622. /**
  55623. * This class is made for on one-liner static method to help creating particle system set.
  55624. */
  55625. export class ParticleHelper {
  55626. /**
  55627. * Gets or sets base Assets URL
  55628. */
  55629. static BaseAssetsUrl: string;
  55630. /**
  55631. * Create a default particle system that you can tweak
  55632. * @param emitter defines the emitter to use
  55633. * @param capacity defines the system capacity (default is 500 particles)
  55634. * @param scene defines the hosting scene
  55635. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55636. * @returns the new Particle system
  55637. */
  55638. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55639. /**
  55640. * This is the main static method (one-liner) of this helper to create different particle systems
  55641. * @param type This string represents the type to the particle system to create
  55642. * @param scene The scene where the particle system should live
  55643. * @param gpu If the system will use gpu
  55644. * @returns the ParticleSystemSet created
  55645. */
  55646. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55647. /**
  55648. * Static function used to export a particle system to a ParticleSystemSet variable.
  55649. * Please note that the emitter shape is not exported
  55650. * @param systems defines the particle systems to export
  55651. * @returns the created particle system set
  55652. */
  55653. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55654. }
  55655. }
  55656. declare module BABYLON {
  55657. interface Engine {
  55658. /**
  55659. * Create an effect to use with particle systems.
  55660. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55661. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55662. * @param uniformsNames defines a list of attribute names
  55663. * @param samplers defines an array of string used to represent textures
  55664. * @param defines defines the string containing the defines to use to compile the shaders
  55665. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55666. * @param onCompiled defines a function to call when the effect creation is successful
  55667. * @param onError defines a function to call when the effect creation has failed
  55668. * @returns the new Effect
  55669. */
  55670. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55671. }
  55672. interface Mesh {
  55673. /**
  55674. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55675. * @returns an array of IParticleSystem
  55676. */
  55677. getEmittedParticleSystems(): IParticleSystem[];
  55678. /**
  55679. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55680. * @returns an array of IParticleSystem
  55681. */
  55682. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55683. }
  55684. /**
  55685. * @hidden
  55686. */
  55687. export var _IDoNeedToBeInTheBuild: number;
  55688. }
  55689. declare module BABYLON {
  55690. interface Scene {
  55691. /** @hidden (Backing field) */
  55692. _physicsEngine: Nullable<IPhysicsEngine>;
  55693. /**
  55694. * Gets the current physics engine
  55695. * @returns a IPhysicsEngine or null if none attached
  55696. */
  55697. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55698. /**
  55699. * Enables physics to the current scene
  55700. * @param gravity defines the scene's gravity for the physics engine
  55701. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55702. * @return a boolean indicating if the physics engine was initialized
  55703. */
  55704. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55705. /**
  55706. * Disables and disposes the physics engine associated with the scene
  55707. */
  55708. disablePhysicsEngine(): void;
  55709. /**
  55710. * Gets a boolean indicating if there is an active physics engine
  55711. * @returns a boolean indicating if there is an active physics engine
  55712. */
  55713. isPhysicsEnabled(): boolean;
  55714. /**
  55715. * Deletes a physics compound impostor
  55716. * @param compound defines the compound to delete
  55717. */
  55718. deleteCompoundImpostor(compound: any): void;
  55719. /**
  55720. * An event triggered when physic simulation is about to be run
  55721. */
  55722. onBeforePhysicsObservable: Observable<Scene>;
  55723. /**
  55724. * An event triggered when physic simulation has been done
  55725. */
  55726. onAfterPhysicsObservable: Observable<Scene>;
  55727. }
  55728. interface AbstractMesh {
  55729. /** @hidden */
  55730. _physicsImpostor: Nullable<PhysicsImpostor>;
  55731. /**
  55732. * Gets or sets impostor used for physic simulation
  55733. * @see http://doc.babylonjs.com/features/physics_engine
  55734. */
  55735. physicsImpostor: Nullable<PhysicsImpostor>;
  55736. /**
  55737. * Gets the current physics impostor
  55738. * @see http://doc.babylonjs.com/features/physics_engine
  55739. * @returns a physics impostor or null
  55740. */
  55741. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55742. /** Apply a physic impulse to the mesh
  55743. * @param force defines the force to apply
  55744. * @param contactPoint defines where to apply the force
  55745. * @returns the current mesh
  55746. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55747. */
  55748. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55749. /**
  55750. * Creates a physic joint between two meshes
  55751. * @param otherMesh defines the other mesh to use
  55752. * @param pivot1 defines the pivot to use on this mesh
  55753. * @param pivot2 defines the pivot to use on the other mesh
  55754. * @param options defines additional options (can be plugin dependent)
  55755. * @returns the current mesh
  55756. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55757. */
  55758. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55759. /** @hidden */
  55760. _disposePhysicsObserver: Nullable<Observer<Node>>;
  55761. }
  55762. /**
  55763. * Defines the physics engine scene component responsible to manage a physics engine
  55764. */
  55765. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55766. /**
  55767. * The component name helpful to identify the component in the list of scene components.
  55768. */
  55769. readonly name: string;
  55770. /**
  55771. * The scene the component belongs to.
  55772. */
  55773. scene: Scene;
  55774. /**
  55775. * Creates a new instance of the component for the given scene
  55776. * @param scene Defines the scene to register the component in
  55777. */
  55778. constructor(scene: Scene);
  55779. /**
  55780. * Registers the component in a given scene
  55781. */
  55782. register(): void;
  55783. /**
  55784. * Rebuilds the elements related to this component in case of
  55785. * context lost for instance.
  55786. */
  55787. rebuild(): void;
  55788. /**
  55789. * Disposes the component and the associated ressources
  55790. */
  55791. dispose(): void;
  55792. }
  55793. }
  55794. declare module BABYLON {
  55795. /**
  55796. * A helper for physics simulations
  55797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55798. */
  55799. export class PhysicsHelper {
  55800. private _scene;
  55801. private _physicsEngine;
  55802. /**
  55803. * Initializes the Physics helper
  55804. * @param scene Babylon.js scene
  55805. */
  55806. constructor(scene: Scene);
  55807. /**
  55808. * Applies a radial explosion impulse
  55809. * @param origin the origin of the explosion
  55810. * @param radiusOrEventOptions the radius or the options of radial explosion
  55811. * @param strength the explosion strength
  55812. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55813. * @returns A physics radial explosion event, or null
  55814. */
  55815. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55816. /**
  55817. * Applies a radial explosion force
  55818. * @param origin the origin of the explosion
  55819. * @param radiusOrEventOptions the radius or the options of radial explosion
  55820. * @param strength the explosion strength
  55821. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55822. * @returns A physics radial explosion event, or null
  55823. */
  55824. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55825. /**
  55826. * Creates a gravitational field
  55827. * @param origin the origin of the explosion
  55828. * @param radiusOrEventOptions the radius or the options of radial explosion
  55829. * @param strength the explosion strength
  55830. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55831. * @returns A physics gravitational field event, or null
  55832. */
  55833. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55834. /**
  55835. * Creates a physics updraft event
  55836. * @param origin the origin of the updraft
  55837. * @param radiusOrEventOptions the radius or the options of the updraft
  55838. * @param strength the strength of the updraft
  55839. * @param height the height of the updraft
  55840. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55841. * @returns A physics updraft event, or null
  55842. */
  55843. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55844. /**
  55845. * Creates a physics vortex event
  55846. * @param origin the of the vortex
  55847. * @param radiusOrEventOptions the radius or the options of the vortex
  55848. * @param strength the strength of the vortex
  55849. * @param height the height of the vortex
  55850. * @returns a Physics vortex event, or null
  55851. * A physics vortex event or null
  55852. */
  55853. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55854. }
  55855. /**
  55856. * Represents a physics radial explosion event
  55857. */
  55858. class PhysicsRadialExplosionEvent {
  55859. private _scene;
  55860. private _options;
  55861. private _sphere;
  55862. private _dataFetched;
  55863. /**
  55864. * Initializes a radial explosioin event
  55865. * @param _scene BabylonJS scene
  55866. * @param _options The options for the vortex event
  55867. */
  55868. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55869. /**
  55870. * Returns the data related to the radial explosion event (sphere).
  55871. * @returns The radial explosion event data
  55872. */
  55873. getData(): PhysicsRadialExplosionEventData;
  55874. /**
  55875. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55876. * @param impostor A physics imposter
  55877. * @param origin the origin of the explosion
  55878. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55879. */
  55880. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55881. /**
  55882. * Triggers affecterd impostors callbacks
  55883. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55884. */
  55885. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55886. /**
  55887. * Disposes the sphere.
  55888. * @param force Specifies if the sphere should be disposed by force
  55889. */
  55890. dispose(force?: boolean): void;
  55891. /*** Helpers ***/
  55892. private _prepareSphere;
  55893. private _intersectsWithSphere;
  55894. }
  55895. /**
  55896. * Represents a gravitational field event
  55897. */
  55898. class PhysicsGravitationalFieldEvent {
  55899. private _physicsHelper;
  55900. private _scene;
  55901. private _origin;
  55902. private _options;
  55903. private _tickCallback;
  55904. private _sphere;
  55905. private _dataFetched;
  55906. /**
  55907. * Initializes the physics gravitational field event
  55908. * @param _physicsHelper A physics helper
  55909. * @param _scene BabylonJS scene
  55910. * @param _origin The origin position of the gravitational field event
  55911. * @param _options The options for the vortex event
  55912. */
  55913. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55914. /**
  55915. * Returns the data related to the gravitational field event (sphere).
  55916. * @returns A gravitational field event
  55917. */
  55918. getData(): PhysicsGravitationalFieldEventData;
  55919. /**
  55920. * Enables the gravitational field.
  55921. */
  55922. enable(): void;
  55923. /**
  55924. * Disables the gravitational field.
  55925. */
  55926. disable(): void;
  55927. /**
  55928. * Disposes the sphere.
  55929. * @param force The force to dispose from the gravitational field event
  55930. */
  55931. dispose(force?: boolean): void;
  55932. private _tick;
  55933. }
  55934. /**
  55935. * Represents a physics updraft event
  55936. */
  55937. class PhysicsUpdraftEvent {
  55938. private _scene;
  55939. private _origin;
  55940. private _options;
  55941. private _physicsEngine;
  55942. private _originTop;
  55943. private _originDirection;
  55944. private _tickCallback;
  55945. private _cylinder;
  55946. private _cylinderPosition;
  55947. private _dataFetched;
  55948. /**
  55949. * Initializes the physics updraft event
  55950. * @param _scene BabylonJS scene
  55951. * @param _origin The origin position of the updraft
  55952. * @param _options The options for the updraft event
  55953. */
  55954. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55955. /**
  55956. * Returns the data related to the updraft event (cylinder).
  55957. * @returns A physics updraft event
  55958. */
  55959. getData(): PhysicsUpdraftEventData;
  55960. /**
  55961. * Enables the updraft.
  55962. */
  55963. enable(): void;
  55964. /**
  55965. * Disables the updraft.
  55966. */
  55967. disable(): void;
  55968. /**
  55969. * Disposes the cylinder.
  55970. * @param force Specifies if the updraft should be disposed by force
  55971. */
  55972. dispose(force?: boolean): void;
  55973. private getImpostorHitData;
  55974. private _tick;
  55975. /*** Helpers ***/
  55976. private _prepareCylinder;
  55977. private _intersectsWithCylinder;
  55978. }
  55979. /**
  55980. * Represents a physics vortex event
  55981. */
  55982. class PhysicsVortexEvent {
  55983. private _scene;
  55984. private _origin;
  55985. private _options;
  55986. private _physicsEngine;
  55987. private _originTop;
  55988. private _tickCallback;
  55989. private _cylinder;
  55990. private _cylinderPosition;
  55991. private _dataFetched;
  55992. /**
  55993. * Initializes the physics vortex event
  55994. * @param _scene The BabylonJS scene
  55995. * @param _origin The origin position of the vortex
  55996. * @param _options The options for the vortex event
  55997. */
  55998. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55999. /**
  56000. * Returns the data related to the vortex event (cylinder).
  56001. * @returns The physics vortex event data
  56002. */
  56003. getData(): PhysicsVortexEventData;
  56004. /**
  56005. * Enables the vortex.
  56006. */
  56007. enable(): void;
  56008. /**
  56009. * Disables the cortex.
  56010. */
  56011. disable(): void;
  56012. /**
  56013. * Disposes the sphere.
  56014. * @param force
  56015. */
  56016. dispose(force?: boolean): void;
  56017. private getImpostorHitData;
  56018. private _tick;
  56019. /*** Helpers ***/
  56020. private _prepareCylinder;
  56021. private _intersectsWithCylinder;
  56022. }
  56023. /**
  56024. * Options fot the radial explosion event
  56025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56026. */
  56027. export class PhysicsRadialExplosionEventOptions {
  56028. /**
  56029. * The radius of the sphere for the radial explosion.
  56030. */
  56031. radius: number;
  56032. /**
  56033. * The strenth of the explosion.
  56034. */
  56035. strength: number;
  56036. /**
  56037. * The strenght of the force in correspondence to the distance of the affected object
  56038. */
  56039. falloff: PhysicsRadialImpulseFalloff;
  56040. /**
  56041. * Sphere options for the radial explosion.
  56042. */
  56043. sphere: {
  56044. segments: number;
  56045. diameter: number;
  56046. };
  56047. /**
  56048. * Sphere options for the radial explosion.
  56049. */
  56050. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56051. }
  56052. /**
  56053. * Options fot the updraft event
  56054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56055. */
  56056. export class PhysicsUpdraftEventOptions {
  56057. /**
  56058. * The radius of the cylinder for the vortex
  56059. */
  56060. radius: number;
  56061. /**
  56062. * The strenth of the updraft.
  56063. */
  56064. strength: number;
  56065. /**
  56066. * The height of the cylinder for the updraft.
  56067. */
  56068. height: number;
  56069. /**
  56070. * The mode for the the updraft.
  56071. */
  56072. updraftMode: PhysicsUpdraftMode;
  56073. }
  56074. /**
  56075. * Options fot the vortex event
  56076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56077. */
  56078. export class PhysicsVortexEventOptions {
  56079. /**
  56080. * The radius of the cylinder for the vortex
  56081. */
  56082. radius: number;
  56083. /**
  56084. * The strenth of the vortex.
  56085. */
  56086. strength: number;
  56087. /**
  56088. * The height of the cylinder for the vortex.
  56089. */
  56090. height: number;
  56091. /**
  56092. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56093. */
  56094. centripetalForceThreshold: number;
  56095. /**
  56096. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56097. */
  56098. centripetalForceMultiplier: number;
  56099. /**
  56100. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56101. */
  56102. centrifugalForceMultiplier: number;
  56103. /**
  56104. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56105. */
  56106. updraftForceMultiplier: number;
  56107. }
  56108. /**
  56109. * The strenght of the force in correspondence to the distance of the affected object
  56110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56111. */
  56112. export enum PhysicsRadialImpulseFalloff {
  56113. /** Defines that impulse is constant in strength across it's whole radius */
  56114. Constant = 0,
  56115. /** Defines that impulse gets weaker if it's further from the origin */
  56116. Linear = 1
  56117. }
  56118. /**
  56119. * The strength of the force in correspondence to the distance of the affected object
  56120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56121. */
  56122. export enum PhysicsUpdraftMode {
  56123. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56124. Center = 0,
  56125. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56126. Perpendicular = 1
  56127. }
  56128. /**
  56129. * Interface for a physics hit data
  56130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56131. */
  56132. export interface PhysicsHitData {
  56133. /**
  56134. * The force applied at the contact point
  56135. */
  56136. force: Vector3;
  56137. /**
  56138. * The contact point
  56139. */
  56140. contactPoint: Vector3;
  56141. /**
  56142. * The distance from the origin to the contact point
  56143. */
  56144. distanceFromOrigin: number;
  56145. }
  56146. /**
  56147. * Interface for radial explosion event data
  56148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56149. */
  56150. export interface PhysicsRadialExplosionEventData {
  56151. /**
  56152. * A sphere used for the radial explosion event
  56153. */
  56154. sphere: Mesh;
  56155. }
  56156. /**
  56157. * Interface for gravitational field event data
  56158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56159. */
  56160. export interface PhysicsGravitationalFieldEventData {
  56161. /**
  56162. * A sphere mesh used for the gravitational field event
  56163. */
  56164. sphere: Mesh;
  56165. }
  56166. /**
  56167. * Interface for updraft event data
  56168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56169. */
  56170. export interface PhysicsUpdraftEventData {
  56171. /**
  56172. * A cylinder used for the updraft event
  56173. */
  56174. cylinder: Mesh;
  56175. }
  56176. /**
  56177. * Interface for vortex event data
  56178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56179. */
  56180. export interface PhysicsVortexEventData {
  56181. /**
  56182. * A cylinder used for the vortex event
  56183. */
  56184. cylinder: Mesh;
  56185. }
  56186. /**
  56187. * Interface for an affected physics impostor
  56188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56189. */
  56190. export interface PhysicsAffectedImpostorWithData {
  56191. /**
  56192. * The impostor affected by the effect
  56193. */
  56194. impostor: PhysicsImpostor;
  56195. /**
  56196. * The data about the hit/horce from the explosion
  56197. */
  56198. hitData: PhysicsHitData;
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /** @hidden */
  56203. export var blackAndWhitePixelShader: {
  56204. name: string;
  56205. shader: string;
  56206. };
  56207. }
  56208. declare module BABYLON {
  56209. /**
  56210. * Post process used to render in black and white
  56211. */
  56212. export class BlackAndWhitePostProcess extends PostProcess {
  56213. /**
  56214. * Linear about to convert he result to black and white (default: 1)
  56215. */
  56216. degree: number;
  56217. /**
  56218. * Creates a black and white post process
  56219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56220. * @param name The name of the effect.
  56221. * @param options The required width/height ratio to downsize to before computing the render pass.
  56222. * @param camera The camera to apply the render pass to.
  56223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56224. * @param engine The engine which the post process will be applied. (default: current engine)
  56225. * @param reusable If the post process can be reused on the same frame. (default: false)
  56226. */
  56227. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56228. }
  56229. }
  56230. declare module BABYLON {
  56231. /**
  56232. * This represents a set of one or more post processes in Babylon.
  56233. * A post process can be used to apply a shader to a texture after it is rendered.
  56234. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56235. */
  56236. export class PostProcessRenderEffect {
  56237. private _postProcesses;
  56238. private _getPostProcesses;
  56239. private _singleInstance;
  56240. private _cameras;
  56241. private _indicesForCamera;
  56242. /**
  56243. * Name of the effect
  56244. * @hidden
  56245. */
  56246. _name: string;
  56247. /**
  56248. * Instantiates a post process render effect.
  56249. * A post process can be used to apply a shader to a texture after it is rendered.
  56250. * @param engine The engine the effect is tied to
  56251. * @param name The name of the effect
  56252. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56253. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56254. */
  56255. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56256. /**
  56257. * Checks if all the post processes in the effect are supported.
  56258. */
  56259. readonly isSupported: boolean;
  56260. /**
  56261. * Updates the current state of the effect
  56262. * @hidden
  56263. */
  56264. _update(): void;
  56265. /**
  56266. * Attaches the effect on cameras
  56267. * @param cameras The camera to attach to.
  56268. * @hidden
  56269. */
  56270. _attachCameras(cameras: Camera): void;
  56271. /**
  56272. * Attaches the effect on cameras
  56273. * @param cameras The camera to attach to.
  56274. * @hidden
  56275. */
  56276. _attachCameras(cameras: Camera[]): void;
  56277. /**
  56278. * Detaches the effect on cameras
  56279. * @param cameras The camera to detatch from.
  56280. * @hidden
  56281. */
  56282. _detachCameras(cameras: Camera): void;
  56283. /**
  56284. * Detatches the effect on cameras
  56285. * @param cameras The camera to detatch from.
  56286. * @hidden
  56287. */
  56288. _detachCameras(cameras: Camera[]): void;
  56289. /**
  56290. * Enables the effect on given cameras
  56291. * @param cameras The camera to enable.
  56292. * @hidden
  56293. */
  56294. _enable(cameras: Camera): void;
  56295. /**
  56296. * Enables the effect on given cameras
  56297. * @param cameras The camera to enable.
  56298. * @hidden
  56299. */
  56300. _enable(cameras: Nullable<Camera[]>): void;
  56301. /**
  56302. * Disables the effect on the given cameras
  56303. * @param cameras The camera to disable.
  56304. * @hidden
  56305. */
  56306. _disable(cameras: Camera): void;
  56307. /**
  56308. * Disables the effect on the given cameras
  56309. * @param cameras The camera to disable.
  56310. * @hidden
  56311. */
  56312. _disable(cameras: Nullable<Camera[]>): void;
  56313. /**
  56314. * Gets a list of the post processes contained in the effect.
  56315. * @param camera The camera to get the post processes on.
  56316. * @returns The list of the post processes in the effect.
  56317. */
  56318. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56319. }
  56320. }
  56321. declare module BABYLON {
  56322. /** @hidden */
  56323. export var extractHighlightsPixelShader: {
  56324. name: string;
  56325. shader: string;
  56326. };
  56327. }
  56328. declare module BABYLON {
  56329. /**
  56330. * 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.
  56331. */
  56332. export class ExtractHighlightsPostProcess extends PostProcess {
  56333. /**
  56334. * The luminance threshold, pixels below this value will be set to black.
  56335. */
  56336. threshold: number;
  56337. /** @hidden */
  56338. _exposure: number;
  56339. /**
  56340. * Post process which has the input texture to be used when performing highlight extraction
  56341. * @hidden
  56342. */
  56343. _inputPostProcess: Nullable<PostProcess>;
  56344. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56345. }
  56346. }
  56347. declare module BABYLON {
  56348. /** @hidden */
  56349. export var bloomMergePixelShader: {
  56350. name: string;
  56351. shader: string;
  56352. };
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56357. */
  56358. export class BloomMergePostProcess extends PostProcess {
  56359. /** Weight of the bloom to be added to the original input. */
  56360. weight: number;
  56361. /**
  56362. * Creates a new instance of @see BloomMergePostProcess
  56363. * @param name The name of the effect.
  56364. * @param originalFromInput Post process which's input will be used for the merge.
  56365. * @param blurred Blurred highlights post process which's output will be used.
  56366. * @param weight Weight of the bloom to be added to the original input.
  56367. * @param options The required width/height ratio to downsize to before computing the render pass.
  56368. * @param camera The camera to apply the render pass to.
  56369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56370. * @param engine The engine which the post process will be applied. (default: current engine)
  56371. * @param reusable If the post process can be reused on the same frame. (default: false)
  56372. * @param textureType Type of textures used when performing the post process. (default: 0)
  56373. * @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)
  56374. */
  56375. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56376. /** Weight of the bloom to be added to the original input. */
  56377. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56378. }
  56379. }
  56380. declare module BABYLON {
  56381. /**
  56382. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56383. */
  56384. export class BloomEffect extends PostProcessRenderEffect {
  56385. private bloomScale;
  56386. /**
  56387. * @hidden Internal
  56388. */
  56389. _effects: Array<PostProcess>;
  56390. /**
  56391. * @hidden Internal
  56392. */
  56393. _downscale: ExtractHighlightsPostProcess;
  56394. private _blurX;
  56395. private _blurY;
  56396. private _merge;
  56397. /**
  56398. * The luminance threshold to find bright areas of the image to bloom.
  56399. */
  56400. threshold: number;
  56401. /**
  56402. * The strength of the bloom.
  56403. */
  56404. weight: number;
  56405. /**
  56406. * Specifies the size of the bloom blur kernel, relative to the final output size
  56407. */
  56408. kernel: number;
  56409. /**
  56410. * Creates a new instance of @see BloomEffect
  56411. * @param scene The scene the effect belongs to.
  56412. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56413. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56414. * @param bloomWeight The the strength of bloom.
  56415. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56416. * @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)
  56417. */
  56418. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56419. /**
  56420. * Disposes each of the internal effects for a given camera.
  56421. * @param camera The camera to dispose the effect on.
  56422. */
  56423. disposeEffects(camera: Camera): void;
  56424. /**
  56425. * @hidden Internal
  56426. */
  56427. _updateEffects(): void;
  56428. /**
  56429. * Internal
  56430. * @returns if all the contained post processes are ready.
  56431. * @hidden
  56432. */
  56433. _isReady(): boolean;
  56434. }
  56435. }
  56436. declare module BABYLON {
  56437. /** @hidden */
  56438. export var chromaticAberrationPixelShader: {
  56439. name: string;
  56440. shader: string;
  56441. };
  56442. }
  56443. declare module BABYLON {
  56444. /**
  56445. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56446. */
  56447. export class ChromaticAberrationPostProcess extends PostProcess {
  56448. /**
  56449. * The amount of seperation of rgb channels (default: 30)
  56450. */
  56451. aberrationAmount: number;
  56452. /**
  56453. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56454. */
  56455. radialIntensity: number;
  56456. /**
  56457. * 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))
  56458. */
  56459. direction: Vector2;
  56460. /**
  56461. * 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))
  56462. */
  56463. centerPosition: Vector2;
  56464. /**
  56465. * Creates a new instance ChromaticAberrationPostProcess
  56466. * @param name The name of the effect.
  56467. * @param screenWidth The width of the screen to apply the effect on.
  56468. * @param screenHeight The height of the screen to apply the effect on.
  56469. * @param options The required width/height ratio to downsize to before computing the render pass.
  56470. * @param camera The camera to apply the render pass to.
  56471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56472. * @param engine The engine which the post process will be applied. (default: current engine)
  56473. * @param reusable If the post process can be reused on the same frame. (default: false)
  56474. * @param textureType Type of textures used when performing the post process. (default: 0)
  56475. * @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)
  56476. */
  56477. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56478. }
  56479. }
  56480. declare module BABYLON {
  56481. /** @hidden */
  56482. export var circleOfConfusionPixelShader: {
  56483. name: string;
  56484. shader: string;
  56485. };
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56490. */
  56491. export class CircleOfConfusionPostProcess extends PostProcess {
  56492. /**
  56493. * 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.
  56494. */
  56495. lensSize: number;
  56496. /**
  56497. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56498. */
  56499. fStop: number;
  56500. /**
  56501. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56502. */
  56503. focusDistance: number;
  56504. /**
  56505. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56506. */
  56507. focalLength: number;
  56508. private _depthTexture;
  56509. /**
  56510. * Creates a new instance CircleOfConfusionPostProcess
  56511. * @param name The name of the effect.
  56512. * @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.
  56513. * @param options The required width/height ratio to downsize to before computing the render pass.
  56514. * @param camera The camera to apply the render pass to.
  56515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56516. * @param engine The engine which the post process will be applied. (default: current engine)
  56517. * @param reusable If the post process can be reused on the same frame. (default: false)
  56518. * @param textureType Type of textures used when performing the post process. (default: 0)
  56519. * @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)
  56520. */
  56521. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56522. /**
  56523. * 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.
  56524. */
  56525. depthTexture: RenderTargetTexture;
  56526. }
  56527. }
  56528. declare module BABYLON {
  56529. /** @hidden */
  56530. export var colorCorrectionPixelShader: {
  56531. name: string;
  56532. shader: string;
  56533. };
  56534. }
  56535. declare module BABYLON {
  56536. /**
  56537. *
  56538. * This post-process allows the modification of rendered colors by using
  56539. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56540. *
  56541. * The object needs to be provided an url to a texture containing the color
  56542. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56543. * Use an image editing software to tweak the LUT to match your needs.
  56544. *
  56545. * For an example of a color LUT, see here:
  56546. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56547. * For explanations on color grading, see here:
  56548. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56549. *
  56550. */
  56551. export class ColorCorrectionPostProcess extends PostProcess {
  56552. private _colorTableTexture;
  56553. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56554. }
  56555. }
  56556. declare module BABYLON {
  56557. /** @hidden */
  56558. export var convolutionPixelShader: {
  56559. name: string;
  56560. shader: string;
  56561. };
  56562. }
  56563. declare module BABYLON {
  56564. /**
  56565. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56566. * input texture to perform effects such as edge detection or sharpening
  56567. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56568. */
  56569. export class ConvolutionPostProcess extends PostProcess {
  56570. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56571. kernel: number[];
  56572. /**
  56573. * Creates a new instance ConvolutionPostProcess
  56574. * @param name The name of the effect.
  56575. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56576. * @param options The required width/height ratio to downsize to before computing the render pass.
  56577. * @param camera The camera to apply the render pass to.
  56578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56579. * @param engine The engine which the post process will be applied. (default: current engine)
  56580. * @param reusable If the post process can be reused on the same frame. (default: false)
  56581. * @param textureType Type of textures used when performing the post process. (default: 0)
  56582. */
  56583. constructor(name: string,
  56584. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56585. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56586. /**
  56587. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56588. */
  56589. static EdgeDetect0Kernel: number[];
  56590. /**
  56591. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56592. */
  56593. static EdgeDetect1Kernel: number[];
  56594. /**
  56595. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56596. */
  56597. static EdgeDetect2Kernel: number[];
  56598. /**
  56599. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56600. */
  56601. static SharpenKernel: number[];
  56602. /**
  56603. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56604. */
  56605. static EmbossKernel: number[];
  56606. /**
  56607. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56608. */
  56609. static GaussianKernel: number[];
  56610. }
  56611. }
  56612. declare module BABYLON {
  56613. /**
  56614. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56615. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56616. * based on samples that have a large difference in distance than the center pixel.
  56617. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56618. */
  56619. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56620. direction: Vector2;
  56621. /**
  56622. * Creates a new instance CircleOfConfusionPostProcess
  56623. * @param name The name of the effect.
  56624. * @param scene The scene the effect belongs to.
  56625. * @param direction The direction the blur should be applied.
  56626. * @param kernel The size of the kernel used to blur.
  56627. * @param options The required width/height ratio to downsize to before computing the render pass.
  56628. * @param camera The camera to apply the render pass to.
  56629. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56630. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56632. * @param engine The engine which the post process will be applied. (default: current engine)
  56633. * @param reusable If the post process can be reused on the same frame. (default: false)
  56634. * @param textureType Type of textures used when performing the post process. (default: 0)
  56635. * @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)
  56636. */
  56637. 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);
  56638. }
  56639. }
  56640. declare module BABYLON {
  56641. /** @hidden */
  56642. export var depthOfFieldMergePixelShader: {
  56643. name: string;
  56644. shader: string;
  56645. };
  56646. }
  56647. declare module BABYLON {
  56648. /**
  56649. * Options to be set when merging outputs from the default pipeline.
  56650. */
  56651. export class DepthOfFieldMergePostProcessOptions {
  56652. /**
  56653. * The original image to merge on top of
  56654. */
  56655. originalFromInput: PostProcess;
  56656. /**
  56657. * Parameters to perform the merge of the depth of field effect
  56658. */
  56659. depthOfField?: {
  56660. circleOfConfusion: PostProcess;
  56661. blurSteps: Array<PostProcess>;
  56662. };
  56663. /**
  56664. * Parameters to perform the merge of bloom effect
  56665. */
  56666. bloom?: {
  56667. blurred: PostProcess;
  56668. weight: number;
  56669. };
  56670. }
  56671. /**
  56672. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56673. */
  56674. export class DepthOfFieldMergePostProcess extends PostProcess {
  56675. private blurSteps;
  56676. /**
  56677. * Creates a new instance of DepthOfFieldMergePostProcess
  56678. * @param name The name of the effect.
  56679. * @param originalFromInput Post process which's input will be used for the merge.
  56680. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56681. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56682. * @param options The required width/height ratio to downsize to before computing the render pass.
  56683. * @param camera The camera to apply the render pass to.
  56684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56685. * @param engine The engine which the post process will be applied. (default: current engine)
  56686. * @param reusable If the post process can be reused on the same frame. (default: false)
  56687. * @param textureType Type of textures used when performing the post process. (default: 0)
  56688. * @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)
  56689. */
  56690. 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);
  56691. /**
  56692. * Updates the effect with the current post process compile time values and recompiles the shader.
  56693. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56694. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56695. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56696. * @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
  56697. * @param onCompiled Called when the shader has been compiled.
  56698. * @param onError Called if there is an error when compiling a shader.
  56699. */
  56700. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56701. }
  56702. }
  56703. declare module BABYLON {
  56704. /**
  56705. * Specifies the level of max blur that should be applied when using the depth of field effect
  56706. */
  56707. export enum DepthOfFieldEffectBlurLevel {
  56708. /**
  56709. * Subtle blur
  56710. */
  56711. Low = 0,
  56712. /**
  56713. * Medium blur
  56714. */
  56715. Medium = 1,
  56716. /**
  56717. * Large blur
  56718. */
  56719. High = 2
  56720. }
  56721. /**
  56722. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56723. */
  56724. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56725. private _circleOfConfusion;
  56726. /**
  56727. * @hidden Internal, blurs from high to low
  56728. */
  56729. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56730. private _depthOfFieldBlurY;
  56731. private _dofMerge;
  56732. /**
  56733. * @hidden Internal post processes in depth of field effect
  56734. */
  56735. _effects: Array<PostProcess>;
  56736. /**
  56737. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56738. */
  56739. focalLength: number;
  56740. /**
  56741. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56742. */
  56743. fStop: number;
  56744. /**
  56745. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56746. */
  56747. focusDistance: number;
  56748. /**
  56749. * 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.
  56750. */
  56751. lensSize: number;
  56752. /**
  56753. * Creates a new instance DepthOfFieldEffect
  56754. * @param scene The scene the effect belongs to.
  56755. * @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.
  56756. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56757. * @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)
  56758. */
  56759. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56760. /**
  56761. * Get the current class name of the current effet
  56762. * @returns "DepthOfFieldEffect"
  56763. */
  56764. getClassName(): string;
  56765. /**
  56766. * 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.
  56767. */
  56768. depthTexture: RenderTargetTexture;
  56769. /**
  56770. * Disposes each of the internal effects for a given camera.
  56771. * @param camera The camera to dispose the effect on.
  56772. */
  56773. disposeEffects(camera: Camera): void;
  56774. /**
  56775. * @hidden Internal
  56776. */
  56777. _updateEffects(): void;
  56778. /**
  56779. * Internal
  56780. * @returns if all the contained post processes are ready.
  56781. * @hidden
  56782. */
  56783. _isReady(): boolean;
  56784. }
  56785. }
  56786. declare module BABYLON {
  56787. /** @hidden */
  56788. export var displayPassPixelShader: {
  56789. name: string;
  56790. shader: string;
  56791. };
  56792. }
  56793. declare module BABYLON {
  56794. /**
  56795. * DisplayPassPostProcess which produces an output the same as it's input
  56796. */
  56797. export class DisplayPassPostProcess extends PostProcess {
  56798. /**
  56799. * Creates the DisplayPassPostProcess
  56800. * @param name The name of the effect.
  56801. * @param options The required width/height ratio to downsize to before computing the render pass.
  56802. * @param camera The camera to apply the render pass to.
  56803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56804. * @param engine The engine which the post process will be applied. (default: current engine)
  56805. * @param reusable If the post process can be reused on the same frame. (default: false)
  56806. */
  56807. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56808. }
  56809. }
  56810. declare module BABYLON {
  56811. /** @hidden */
  56812. export var filterPixelShader: {
  56813. name: string;
  56814. shader: string;
  56815. };
  56816. }
  56817. declare module BABYLON {
  56818. /**
  56819. * Applies a kernel filter to the image
  56820. */
  56821. export class FilterPostProcess extends PostProcess {
  56822. /** The matrix to be applied to the image */
  56823. kernelMatrix: Matrix;
  56824. /**
  56825. *
  56826. * @param name The name of the effect.
  56827. * @param kernelMatrix The matrix to be applied to the image
  56828. * @param options The required width/height ratio to downsize to before computing the render pass.
  56829. * @param camera The camera to apply the render pass to.
  56830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56831. * @param engine The engine which the post process will be applied. (default: current engine)
  56832. * @param reusable If the post process can be reused on the same frame. (default: false)
  56833. */
  56834. constructor(name: string,
  56835. /** The matrix to be applied to the image */
  56836. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56837. }
  56838. }
  56839. declare module BABYLON {
  56840. /** @hidden */
  56841. export var fxaaPixelShader: {
  56842. name: string;
  56843. shader: string;
  56844. };
  56845. }
  56846. declare module BABYLON {
  56847. /** @hidden */
  56848. export var fxaaVertexShader: {
  56849. name: string;
  56850. shader: string;
  56851. };
  56852. }
  56853. declare module BABYLON {
  56854. /**
  56855. * Fxaa post process
  56856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56857. */
  56858. export class FxaaPostProcess extends PostProcess {
  56859. /** @hidden */
  56860. texelWidth: number;
  56861. /** @hidden */
  56862. texelHeight: number;
  56863. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56864. private _getDefines;
  56865. }
  56866. }
  56867. declare module BABYLON {
  56868. /** @hidden */
  56869. export var grainPixelShader: {
  56870. name: string;
  56871. shader: string;
  56872. };
  56873. }
  56874. declare module BABYLON {
  56875. /**
  56876. * The GrainPostProcess adds noise to the image at mid luminance levels
  56877. */
  56878. export class GrainPostProcess extends PostProcess {
  56879. /**
  56880. * The intensity of the grain added (default: 30)
  56881. */
  56882. intensity: number;
  56883. /**
  56884. * If the grain should be randomized on every frame
  56885. */
  56886. animated: boolean;
  56887. /**
  56888. * Creates a new instance of @see GrainPostProcess
  56889. * @param name The name of the effect.
  56890. * @param options The required width/height ratio to downsize to before computing the render pass.
  56891. * @param camera The camera to apply the render pass to.
  56892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56893. * @param engine The engine which the post process will be applied. (default: current engine)
  56894. * @param reusable If the post process can be reused on the same frame. (default: false)
  56895. * @param textureType Type of textures used when performing the post process. (default: 0)
  56896. * @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)
  56897. */
  56898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /** @hidden */
  56903. export var highlightsPixelShader: {
  56904. name: string;
  56905. shader: string;
  56906. };
  56907. }
  56908. declare module BABYLON {
  56909. /**
  56910. * Extracts highlights from the image
  56911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56912. */
  56913. export class HighlightsPostProcess extends PostProcess {
  56914. /**
  56915. * Extracts highlights from the image
  56916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56917. * @param name The name of the effect.
  56918. * @param options The required width/height ratio to downsize to before computing the render pass.
  56919. * @param camera The camera to apply the render pass to.
  56920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56921. * @param engine The engine which the post process will be applied. (default: current engine)
  56922. * @param reusable If the post process can be reused on the same frame. (default: false)
  56923. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56924. */
  56925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56926. }
  56927. }
  56928. declare module BABYLON {
  56929. /** @hidden */
  56930. export var mrtFragmentDeclaration: {
  56931. name: string;
  56932. shader: string;
  56933. };
  56934. }
  56935. declare module BABYLON {
  56936. /** @hidden */
  56937. export var geometryPixelShader: {
  56938. name: string;
  56939. shader: string;
  56940. };
  56941. }
  56942. declare module BABYLON {
  56943. /** @hidden */
  56944. export var geometryVertexShader: {
  56945. name: string;
  56946. shader: string;
  56947. };
  56948. }
  56949. declare module BABYLON {
  56950. /** @hidden */
  56951. interface ISavedTransformationMatrix {
  56952. world: Matrix;
  56953. viewProjection: Matrix;
  56954. }
  56955. /**
  56956. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56957. */
  56958. export class GeometryBufferRenderer {
  56959. /**
  56960. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56961. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56962. */
  56963. static readonly POSITION_TEXTURE_TYPE: number;
  56964. /**
  56965. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56966. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56967. */
  56968. static readonly VELOCITY_TEXTURE_TYPE: number;
  56969. /**
  56970. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56971. * in order to compute objects velocities when enableVelocity is set to "true"
  56972. * @hidden
  56973. */
  56974. _previousTransformationMatrices: {
  56975. [index: number]: ISavedTransformationMatrix;
  56976. };
  56977. /**
  56978. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56979. * in order to compute objects velocities when enableVelocity is set to "true"
  56980. * @hidden
  56981. */
  56982. _previousBonesTransformationMatrices: {
  56983. [index: number]: Float32Array;
  56984. };
  56985. /**
  56986. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56987. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56988. */
  56989. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56990. private _scene;
  56991. private _multiRenderTarget;
  56992. private _ratio;
  56993. private _enablePosition;
  56994. private _enableVelocity;
  56995. private _positionIndex;
  56996. private _velocityIndex;
  56997. protected _effect: Effect;
  56998. protected _cachedDefines: string;
  56999. /**
  57000. * Set the render list (meshes to be rendered) used in the G buffer.
  57001. */
  57002. renderList: Mesh[];
  57003. /**
  57004. * Gets wether or not G buffer are supported by the running hardware.
  57005. * This requires draw buffer supports
  57006. */
  57007. readonly isSupported: boolean;
  57008. /**
  57009. * Returns the index of the given texture type in the G-Buffer textures array
  57010. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57011. * @returns the index of the given texture type in the G-Buffer textures array
  57012. */
  57013. getTextureIndex(textureType: number): number;
  57014. /**
  57015. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57016. */
  57017. /**
  57018. * Sets whether or not objects positions are enabled for the G buffer.
  57019. */
  57020. enablePosition: boolean;
  57021. /**
  57022. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57023. */
  57024. /**
  57025. * Sets wether or not objects velocities are enabled for the G buffer.
  57026. */
  57027. enableVelocity: boolean;
  57028. /**
  57029. * Gets the scene associated with the buffer.
  57030. */
  57031. readonly scene: Scene;
  57032. /**
  57033. * Gets the ratio used by the buffer during its creation.
  57034. * How big is the buffer related to the main canvas.
  57035. */
  57036. readonly ratio: number;
  57037. /** @hidden */
  57038. static _SceneComponentInitialization: (scene: Scene) => void;
  57039. /**
  57040. * Creates a new G Buffer for the scene
  57041. * @param scene The scene the buffer belongs to
  57042. * @param ratio How big is the buffer related to the main canvas.
  57043. */
  57044. constructor(scene: Scene, ratio?: number);
  57045. /**
  57046. * Checks wether everything is ready to render a submesh to the G buffer.
  57047. * @param subMesh the submesh to check readiness for
  57048. * @param useInstances is the mesh drawn using instance or not
  57049. * @returns true if ready otherwise false
  57050. */
  57051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57052. /**
  57053. * Gets the current underlying G Buffer.
  57054. * @returns the buffer
  57055. */
  57056. getGBuffer(): MultiRenderTarget;
  57057. /**
  57058. * Gets the number of samples used to render the buffer (anti aliasing).
  57059. */
  57060. /**
  57061. * Sets the number of samples used to render the buffer (anti aliasing).
  57062. */
  57063. samples: number;
  57064. /**
  57065. * Disposes the renderer and frees up associated resources.
  57066. */
  57067. dispose(): void;
  57068. protected _createRenderTargets(): void;
  57069. private _copyBonesTransformationMatrices;
  57070. }
  57071. }
  57072. declare module BABYLON {
  57073. interface Scene {
  57074. /** @hidden (Backing field) */
  57075. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57076. /**
  57077. * Gets or Sets the current geometry buffer associated to the scene.
  57078. */
  57079. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57080. /**
  57081. * Enables a GeometryBufferRender and associates it with the scene
  57082. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57083. * @returns the GeometryBufferRenderer
  57084. */
  57085. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57086. /**
  57087. * Disables the GeometryBufferRender associated with the scene
  57088. */
  57089. disableGeometryBufferRenderer(): void;
  57090. }
  57091. /**
  57092. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57093. * in several rendering techniques.
  57094. */
  57095. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57096. /**
  57097. * The component name helpful to identify the component in the list of scene components.
  57098. */
  57099. readonly name: string;
  57100. /**
  57101. * The scene the component belongs to.
  57102. */
  57103. scene: Scene;
  57104. /**
  57105. * Creates a new instance of the component for the given scene
  57106. * @param scene Defines the scene to register the component in
  57107. */
  57108. constructor(scene: Scene);
  57109. /**
  57110. * Registers the component in a given scene
  57111. */
  57112. register(): void;
  57113. /**
  57114. * Rebuilds the elements related to this component in case of
  57115. * context lost for instance.
  57116. */
  57117. rebuild(): void;
  57118. /**
  57119. * Disposes the component and the associated ressources
  57120. */
  57121. dispose(): void;
  57122. private _gatherRenderTargets;
  57123. }
  57124. }
  57125. declare module BABYLON {
  57126. /** @hidden */
  57127. export var motionBlurPixelShader: {
  57128. name: string;
  57129. shader: string;
  57130. };
  57131. }
  57132. declare module BABYLON {
  57133. /**
  57134. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57135. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57136. * As an example, all you have to do is to create the post-process:
  57137. * var mb = new BABYLON.MotionBlurPostProcess(
  57138. * 'mb', // The name of the effect.
  57139. * scene, // The scene containing the objects to blur according to their velocity.
  57140. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57141. * camera // The camera to apply the render pass to.
  57142. * );
  57143. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57144. */
  57145. export class MotionBlurPostProcess extends PostProcess {
  57146. /**
  57147. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57148. */
  57149. motionStrength: number;
  57150. /**
  57151. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57152. */
  57153. /**
  57154. * Sets the number of iterations to be used for motion blur quality
  57155. */
  57156. motionBlurSamples: number;
  57157. private _motionBlurSamples;
  57158. private _geometryBufferRenderer;
  57159. /**
  57160. * Creates a new instance MotionBlurPostProcess
  57161. * @param name The name of the effect.
  57162. * @param scene The scene containing the objects to blur according to their velocity.
  57163. * @param options The required width/height ratio to downsize to before computing the render pass.
  57164. * @param camera The camera to apply the render pass to.
  57165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57166. * @param engine The engine which the post process will be applied. (default: current engine)
  57167. * @param reusable If the post process can be reused on the same frame. (default: false)
  57168. * @param textureType Type of textures used when performing the post process. (default: 0)
  57169. * @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)
  57170. */
  57171. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57172. /**
  57173. * Excludes the given skinned mesh from computing bones velocities.
  57174. * 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.
  57175. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57176. */
  57177. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57178. /**
  57179. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57180. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57181. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57182. */
  57183. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57184. /**
  57185. * Disposes the post process.
  57186. * @param camera The camera to dispose the post process on.
  57187. */
  57188. dispose(camera?: Camera): void;
  57189. }
  57190. }
  57191. declare module BABYLON {
  57192. /** @hidden */
  57193. export var refractionPixelShader: {
  57194. name: string;
  57195. shader: string;
  57196. };
  57197. }
  57198. declare module BABYLON {
  57199. /**
  57200. * Post process which applies a refractin texture
  57201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57202. */
  57203. export class RefractionPostProcess extends PostProcess {
  57204. /** the base color of the refraction (used to taint the rendering) */
  57205. color: Color3;
  57206. /** simulated refraction depth */
  57207. depth: number;
  57208. /** the coefficient of the base color (0 to remove base color tainting) */
  57209. colorLevel: number;
  57210. private _refTexture;
  57211. private _ownRefractionTexture;
  57212. /**
  57213. * Gets or sets the refraction texture
  57214. * Please note that you are responsible for disposing the texture if you set it manually
  57215. */
  57216. refractionTexture: Texture;
  57217. /**
  57218. * Initializes the RefractionPostProcess
  57219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57220. * @param name The name of the effect.
  57221. * @param refractionTextureUrl Url of the refraction texture to use
  57222. * @param color the base color of the refraction (used to taint the rendering)
  57223. * @param depth simulated refraction depth
  57224. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57225. * @param camera The camera to apply the render pass to.
  57226. * @param options The required width/height ratio to downsize to before computing the render pass.
  57227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57228. * @param engine The engine which the post process will be applied. (default: current engine)
  57229. * @param reusable If the post process can be reused on the same frame. (default: false)
  57230. */
  57231. constructor(name: string, refractionTextureUrl: string,
  57232. /** the base color of the refraction (used to taint the rendering) */
  57233. color: Color3,
  57234. /** simulated refraction depth */
  57235. depth: number,
  57236. /** the coefficient of the base color (0 to remove base color tainting) */
  57237. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57238. /**
  57239. * Disposes of the post process
  57240. * @param camera Camera to dispose post process on
  57241. */
  57242. dispose(camera: Camera): void;
  57243. }
  57244. }
  57245. declare module BABYLON {
  57246. /** @hidden */
  57247. export var sharpenPixelShader: {
  57248. name: string;
  57249. shader: string;
  57250. };
  57251. }
  57252. declare module BABYLON {
  57253. /**
  57254. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57255. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57256. */
  57257. export class SharpenPostProcess extends PostProcess {
  57258. /**
  57259. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57260. */
  57261. colorAmount: number;
  57262. /**
  57263. * How much sharpness should be applied (default: 0.3)
  57264. */
  57265. edgeAmount: number;
  57266. /**
  57267. * Creates a new instance ConvolutionPostProcess
  57268. * @param name The name of the effect.
  57269. * @param options The required width/height ratio to downsize to before computing the render pass.
  57270. * @param camera The camera to apply the render pass to.
  57271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57272. * @param engine The engine which the post process will be applied. (default: current engine)
  57273. * @param reusable If the post process can be reused on the same frame. (default: false)
  57274. * @param textureType Type of textures used when performing the post process. (default: 0)
  57275. * @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)
  57276. */
  57277. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57278. }
  57279. }
  57280. declare module BABYLON {
  57281. /**
  57282. * PostProcessRenderPipeline
  57283. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57284. */
  57285. export class PostProcessRenderPipeline {
  57286. private engine;
  57287. private _renderEffects;
  57288. private _renderEffectsForIsolatedPass;
  57289. /**
  57290. * List of inspectable custom properties (used by the Inspector)
  57291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57292. */
  57293. inspectableCustomProperties: IInspectable[];
  57294. /**
  57295. * @hidden
  57296. */
  57297. protected _cameras: Camera[];
  57298. /** @hidden */
  57299. _name: string;
  57300. /**
  57301. * Gets pipeline name
  57302. */
  57303. readonly name: string;
  57304. /**
  57305. * Initializes a PostProcessRenderPipeline
  57306. * @param engine engine to add the pipeline to
  57307. * @param name name of the pipeline
  57308. */
  57309. constructor(engine: Engine, name: string);
  57310. /**
  57311. * Gets the class name
  57312. * @returns "PostProcessRenderPipeline"
  57313. */
  57314. getClassName(): string;
  57315. /**
  57316. * If all the render effects in the pipeline are supported
  57317. */
  57318. readonly isSupported: boolean;
  57319. /**
  57320. * Adds an effect to the pipeline
  57321. * @param renderEffect the effect to add
  57322. */
  57323. addEffect(renderEffect: PostProcessRenderEffect): void;
  57324. /** @hidden */
  57325. _rebuild(): void;
  57326. /** @hidden */
  57327. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57328. /** @hidden */
  57329. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57330. /** @hidden */
  57331. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57332. /** @hidden */
  57333. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57334. /** @hidden */
  57335. _attachCameras(cameras: Camera, unique: boolean): void;
  57336. /** @hidden */
  57337. _attachCameras(cameras: Camera[], unique: boolean): void;
  57338. /** @hidden */
  57339. _detachCameras(cameras: Camera): void;
  57340. /** @hidden */
  57341. _detachCameras(cameras: Nullable<Camera[]>): void;
  57342. /** @hidden */
  57343. _update(): void;
  57344. /** @hidden */
  57345. _reset(): void;
  57346. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57347. /**
  57348. * Disposes of the pipeline
  57349. */
  57350. dispose(): void;
  57351. }
  57352. }
  57353. declare module BABYLON {
  57354. /**
  57355. * PostProcessRenderPipelineManager class
  57356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57357. */
  57358. export class PostProcessRenderPipelineManager {
  57359. private _renderPipelines;
  57360. /**
  57361. * Initializes a PostProcessRenderPipelineManager
  57362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57363. */
  57364. constructor();
  57365. /**
  57366. * Gets the list of supported render pipelines
  57367. */
  57368. readonly supportedPipelines: PostProcessRenderPipeline[];
  57369. /**
  57370. * Adds a pipeline to the manager
  57371. * @param renderPipeline The pipeline to add
  57372. */
  57373. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57374. /**
  57375. * Attaches a camera to the pipeline
  57376. * @param renderPipelineName The name of the pipeline to attach to
  57377. * @param cameras the camera to attach
  57378. * @param unique if the camera can be attached multiple times to the pipeline
  57379. */
  57380. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57381. /**
  57382. * Detaches a camera from the pipeline
  57383. * @param renderPipelineName The name of the pipeline to detach from
  57384. * @param cameras the camera to detach
  57385. */
  57386. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57387. /**
  57388. * Enables an effect by name on a pipeline
  57389. * @param renderPipelineName the name of the pipeline to enable the effect in
  57390. * @param renderEffectName the name of the effect to enable
  57391. * @param cameras the cameras that the effect should be enabled on
  57392. */
  57393. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57394. /**
  57395. * Disables an effect by name on a pipeline
  57396. * @param renderPipelineName the name of the pipeline to disable the effect in
  57397. * @param renderEffectName the name of the effect to disable
  57398. * @param cameras the cameras that the effect should be disabled on
  57399. */
  57400. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57401. /**
  57402. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57403. */
  57404. update(): void;
  57405. /** @hidden */
  57406. _rebuild(): void;
  57407. /**
  57408. * Disposes of the manager and pipelines
  57409. */
  57410. dispose(): void;
  57411. }
  57412. }
  57413. declare module BABYLON {
  57414. interface Scene {
  57415. /** @hidden (Backing field) */
  57416. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57417. /**
  57418. * Gets the postprocess render pipeline manager
  57419. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57420. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57421. */
  57422. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57423. }
  57424. /**
  57425. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57426. */
  57427. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57428. /**
  57429. * The component name helpfull to identify the component in the list of scene components.
  57430. */
  57431. readonly name: string;
  57432. /**
  57433. * The scene the component belongs to.
  57434. */
  57435. scene: Scene;
  57436. /**
  57437. * Creates a new instance of the component for the given scene
  57438. * @param scene Defines the scene to register the component in
  57439. */
  57440. constructor(scene: Scene);
  57441. /**
  57442. * Registers the component in a given scene
  57443. */
  57444. register(): void;
  57445. /**
  57446. * Rebuilds the elements related to this component in case of
  57447. * context lost for instance.
  57448. */
  57449. rebuild(): void;
  57450. /**
  57451. * Disposes the component and the associated ressources
  57452. */
  57453. dispose(): void;
  57454. private _gatherRenderTargets;
  57455. }
  57456. }
  57457. declare module BABYLON {
  57458. /**
  57459. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57460. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57461. */
  57462. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57463. private _scene;
  57464. private _camerasToBeAttached;
  57465. /**
  57466. * ID of the sharpen post process,
  57467. */
  57468. private readonly SharpenPostProcessId;
  57469. /**
  57470. * @ignore
  57471. * ID of the image processing post process;
  57472. */
  57473. readonly ImageProcessingPostProcessId: string;
  57474. /**
  57475. * @ignore
  57476. * ID of the Fast Approximate Anti-Aliasing post process;
  57477. */
  57478. readonly FxaaPostProcessId: string;
  57479. /**
  57480. * ID of the chromatic aberration post process,
  57481. */
  57482. private readonly ChromaticAberrationPostProcessId;
  57483. /**
  57484. * ID of the grain post process
  57485. */
  57486. private readonly GrainPostProcessId;
  57487. /**
  57488. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57489. */
  57490. sharpen: SharpenPostProcess;
  57491. private _sharpenEffect;
  57492. private bloom;
  57493. /**
  57494. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57495. */
  57496. depthOfField: DepthOfFieldEffect;
  57497. /**
  57498. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57499. */
  57500. fxaa: FxaaPostProcess;
  57501. /**
  57502. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57503. */
  57504. imageProcessing: ImageProcessingPostProcess;
  57505. /**
  57506. * Chromatic aberration post process which will shift rgb colors in the image
  57507. */
  57508. chromaticAberration: ChromaticAberrationPostProcess;
  57509. private _chromaticAberrationEffect;
  57510. /**
  57511. * Grain post process which add noise to the image
  57512. */
  57513. grain: GrainPostProcess;
  57514. private _grainEffect;
  57515. /**
  57516. * Glow post process which adds a glow to emissive areas of the image
  57517. */
  57518. private _glowLayer;
  57519. /**
  57520. * Animations which can be used to tweak settings over a period of time
  57521. */
  57522. animations: Animation[];
  57523. private _imageProcessingConfigurationObserver;
  57524. private _sharpenEnabled;
  57525. private _bloomEnabled;
  57526. private _depthOfFieldEnabled;
  57527. private _depthOfFieldBlurLevel;
  57528. private _fxaaEnabled;
  57529. private _imageProcessingEnabled;
  57530. private _defaultPipelineTextureType;
  57531. private _bloomScale;
  57532. private _chromaticAberrationEnabled;
  57533. private _grainEnabled;
  57534. private _buildAllowed;
  57535. /**
  57536. * Gets active scene
  57537. */
  57538. readonly scene: Scene;
  57539. /**
  57540. * Enable or disable the sharpen process from the pipeline
  57541. */
  57542. sharpenEnabled: boolean;
  57543. private _resizeObserver;
  57544. private _hardwareScaleLevel;
  57545. private _bloomKernel;
  57546. /**
  57547. * Specifies the size of the bloom blur kernel, relative to the final output size
  57548. */
  57549. bloomKernel: number;
  57550. /**
  57551. * Specifies the weight of the bloom in the final rendering
  57552. */
  57553. private _bloomWeight;
  57554. /**
  57555. * Specifies the luma threshold for the area that will be blurred by the bloom
  57556. */
  57557. private _bloomThreshold;
  57558. private _hdr;
  57559. /**
  57560. * The strength of the bloom.
  57561. */
  57562. bloomWeight: number;
  57563. /**
  57564. * The strength of the bloom.
  57565. */
  57566. bloomThreshold: number;
  57567. /**
  57568. * The scale of the bloom, lower value will provide better performance.
  57569. */
  57570. bloomScale: number;
  57571. /**
  57572. * Enable or disable the bloom from the pipeline
  57573. */
  57574. bloomEnabled: boolean;
  57575. private _rebuildBloom;
  57576. /**
  57577. * If the depth of field is enabled.
  57578. */
  57579. depthOfFieldEnabled: boolean;
  57580. /**
  57581. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57582. */
  57583. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57584. /**
  57585. * If the anti aliasing is enabled.
  57586. */
  57587. fxaaEnabled: boolean;
  57588. private _samples;
  57589. /**
  57590. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57591. */
  57592. samples: number;
  57593. /**
  57594. * If image processing is enabled.
  57595. */
  57596. imageProcessingEnabled: boolean;
  57597. /**
  57598. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57599. */
  57600. glowLayerEnabled: boolean;
  57601. /**
  57602. * Gets the glow layer (or null if not defined)
  57603. */
  57604. readonly glowLayer: Nullable<GlowLayer>;
  57605. /**
  57606. * Enable or disable the chromaticAberration process from the pipeline
  57607. */
  57608. chromaticAberrationEnabled: boolean;
  57609. /**
  57610. * Enable or disable the grain process from the pipeline
  57611. */
  57612. grainEnabled: boolean;
  57613. /**
  57614. * @constructor
  57615. * @param name - The rendering pipeline name (default: "")
  57616. * @param hdr - If high dynamic range textures should be used (default: true)
  57617. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57618. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57619. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57620. */
  57621. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57622. /**
  57623. * Get the class name
  57624. * @returns "DefaultRenderingPipeline"
  57625. */
  57626. getClassName(): string;
  57627. /**
  57628. * Force the compilation of the entire pipeline.
  57629. */
  57630. prepare(): void;
  57631. private _hasCleared;
  57632. private _prevPostProcess;
  57633. private _prevPrevPostProcess;
  57634. private _setAutoClearAndTextureSharing;
  57635. private _depthOfFieldSceneObserver;
  57636. private _buildPipeline;
  57637. private _disposePostProcesses;
  57638. /**
  57639. * Adds a camera to the pipeline
  57640. * @param camera the camera to be added
  57641. */
  57642. addCamera(camera: Camera): void;
  57643. /**
  57644. * Removes a camera from the pipeline
  57645. * @param camera the camera to remove
  57646. */
  57647. removeCamera(camera: Camera): void;
  57648. /**
  57649. * Dispose of the pipeline and stop all post processes
  57650. */
  57651. dispose(): void;
  57652. /**
  57653. * Serialize the rendering pipeline (Used when exporting)
  57654. * @returns the serialized object
  57655. */
  57656. serialize(): any;
  57657. /**
  57658. * Parse the serialized pipeline
  57659. * @param source Source pipeline.
  57660. * @param scene The scene to load the pipeline to.
  57661. * @param rootUrl The URL of the serialized pipeline.
  57662. * @returns An instantiated pipeline from the serialized object.
  57663. */
  57664. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57665. }
  57666. }
  57667. declare module BABYLON {
  57668. /** @hidden */
  57669. export var lensHighlightsPixelShader: {
  57670. name: string;
  57671. shader: string;
  57672. };
  57673. }
  57674. declare module BABYLON {
  57675. /** @hidden */
  57676. export var depthOfFieldPixelShader: {
  57677. name: string;
  57678. shader: string;
  57679. };
  57680. }
  57681. declare module BABYLON {
  57682. /**
  57683. * BABYLON.JS Chromatic Aberration GLSL Shader
  57684. * Author: Olivier Guyot
  57685. * Separates very slightly R, G and B colors on the edges of the screen
  57686. * Inspired by Francois Tarlier & Martins Upitis
  57687. */
  57688. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57689. /**
  57690. * @ignore
  57691. * The chromatic aberration PostProcess id in the pipeline
  57692. */
  57693. LensChromaticAberrationEffect: string;
  57694. /**
  57695. * @ignore
  57696. * The highlights enhancing PostProcess id in the pipeline
  57697. */
  57698. HighlightsEnhancingEffect: string;
  57699. /**
  57700. * @ignore
  57701. * The depth-of-field PostProcess id in the pipeline
  57702. */
  57703. LensDepthOfFieldEffect: string;
  57704. private _scene;
  57705. private _depthTexture;
  57706. private _grainTexture;
  57707. private _chromaticAberrationPostProcess;
  57708. private _highlightsPostProcess;
  57709. private _depthOfFieldPostProcess;
  57710. private _edgeBlur;
  57711. private _grainAmount;
  57712. private _chromaticAberration;
  57713. private _distortion;
  57714. private _highlightsGain;
  57715. private _highlightsThreshold;
  57716. private _dofDistance;
  57717. private _dofAperture;
  57718. private _dofDarken;
  57719. private _dofPentagon;
  57720. private _blurNoise;
  57721. /**
  57722. * @constructor
  57723. *
  57724. * Effect parameters are as follow:
  57725. * {
  57726. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57727. * edge_blur: number; // from 0 to x (1 for realism)
  57728. * distortion: number; // from 0 to x (1 for realism)
  57729. * grain_amount: number; // from 0 to 1
  57730. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57731. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57732. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57733. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57734. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57735. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57736. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57737. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57738. * }
  57739. * Note: if an effect parameter is unset, effect is disabled
  57740. *
  57741. * @param name The rendering pipeline name
  57742. * @param parameters - An object containing all parameters (see above)
  57743. * @param scene The scene linked to this pipeline
  57744. * @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)
  57745. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57746. */
  57747. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57748. /**
  57749. * Get the class name
  57750. * @returns "LensRenderingPipeline"
  57751. */
  57752. getClassName(): string;
  57753. /**
  57754. * Gets associated scene
  57755. */
  57756. readonly scene: Scene;
  57757. /**
  57758. * Gets or sets the edge blur
  57759. */
  57760. edgeBlur: number;
  57761. /**
  57762. * Gets or sets the grain amount
  57763. */
  57764. grainAmount: number;
  57765. /**
  57766. * Gets or sets the chromatic aberration amount
  57767. */
  57768. chromaticAberration: number;
  57769. /**
  57770. * Gets or sets the depth of field aperture
  57771. */
  57772. dofAperture: number;
  57773. /**
  57774. * Gets or sets the edge distortion
  57775. */
  57776. edgeDistortion: number;
  57777. /**
  57778. * Gets or sets the depth of field distortion
  57779. */
  57780. dofDistortion: number;
  57781. /**
  57782. * Gets or sets the darken out of focus amount
  57783. */
  57784. darkenOutOfFocus: number;
  57785. /**
  57786. * Gets or sets a boolean indicating if blur noise is enabled
  57787. */
  57788. blurNoise: boolean;
  57789. /**
  57790. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57791. */
  57792. pentagonBokeh: boolean;
  57793. /**
  57794. * Gets or sets the highlight grain amount
  57795. */
  57796. highlightsGain: number;
  57797. /**
  57798. * Gets or sets the highlight threshold
  57799. */
  57800. highlightsThreshold: number;
  57801. /**
  57802. * Sets the amount of blur at the edges
  57803. * @param amount blur amount
  57804. */
  57805. setEdgeBlur(amount: number): void;
  57806. /**
  57807. * Sets edge blur to 0
  57808. */
  57809. disableEdgeBlur(): void;
  57810. /**
  57811. * Sets the amout of grain
  57812. * @param amount Amount of grain
  57813. */
  57814. setGrainAmount(amount: number): void;
  57815. /**
  57816. * Set grain amount to 0
  57817. */
  57818. disableGrain(): void;
  57819. /**
  57820. * Sets the chromatic aberration amount
  57821. * @param amount amount of chromatic aberration
  57822. */
  57823. setChromaticAberration(amount: number): void;
  57824. /**
  57825. * Sets chromatic aberration amount to 0
  57826. */
  57827. disableChromaticAberration(): void;
  57828. /**
  57829. * Sets the EdgeDistortion amount
  57830. * @param amount amount of EdgeDistortion
  57831. */
  57832. setEdgeDistortion(amount: number): void;
  57833. /**
  57834. * Sets edge distortion to 0
  57835. */
  57836. disableEdgeDistortion(): void;
  57837. /**
  57838. * Sets the FocusDistance amount
  57839. * @param amount amount of FocusDistance
  57840. */
  57841. setFocusDistance(amount: number): void;
  57842. /**
  57843. * Disables depth of field
  57844. */
  57845. disableDepthOfField(): void;
  57846. /**
  57847. * Sets the Aperture amount
  57848. * @param amount amount of Aperture
  57849. */
  57850. setAperture(amount: number): void;
  57851. /**
  57852. * Sets the DarkenOutOfFocus amount
  57853. * @param amount amount of DarkenOutOfFocus
  57854. */
  57855. setDarkenOutOfFocus(amount: number): void;
  57856. private _pentagonBokehIsEnabled;
  57857. /**
  57858. * Creates a pentagon bokeh effect
  57859. */
  57860. enablePentagonBokeh(): void;
  57861. /**
  57862. * Disables the pentagon bokeh effect
  57863. */
  57864. disablePentagonBokeh(): void;
  57865. /**
  57866. * Enables noise blur
  57867. */
  57868. enableNoiseBlur(): void;
  57869. /**
  57870. * Disables noise blur
  57871. */
  57872. disableNoiseBlur(): void;
  57873. /**
  57874. * Sets the HighlightsGain amount
  57875. * @param amount amount of HighlightsGain
  57876. */
  57877. setHighlightsGain(amount: number): void;
  57878. /**
  57879. * Sets the HighlightsThreshold amount
  57880. * @param amount amount of HighlightsThreshold
  57881. */
  57882. setHighlightsThreshold(amount: number): void;
  57883. /**
  57884. * Disables highlights
  57885. */
  57886. disableHighlights(): void;
  57887. /**
  57888. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57889. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57890. */
  57891. dispose(disableDepthRender?: boolean): void;
  57892. private _createChromaticAberrationPostProcess;
  57893. private _createHighlightsPostProcess;
  57894. private _createDepthOfFieldPostProcess;
  57895. private _createGrainTexture;
  57896. }
  57897. }
  57898. declare module BABYLON {
  57899. /** @hidden */
  57900. export var ssao2PixelShader: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module BABYLON {
  57906. /** @hidden */
  57907. export var ssaoCombinePixelShader: {
  57908. name: string;
  57909. shader: string;
  57910. };
  57911. }
  57912. declare module BABYLON {
  57913. /**
  57914. * Render pipeline to produce ssao effect
  57915. */
  57916. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57917. /**
  57918. * @ignore
  57919. * The PassPostProcess id in the pipeline that contains the original scene color
  57920. */
  57921. SSAOOriginalSceneColorEffect: string;
  57922. /**
  57923. * @ignore
  57924. * The SSAO PostProcess id in the pipeline
  57925. */
  57926. SSAORenderEffect: string;
  57927. /**
  57928. * @ignore
  57929. * The horizontal blur PostProcess id in the pipeline
  57930. */
  57931. SSAOBlurHRenderEffect: string;
  57932. /**
  57933. * @ignore
  57934. * The vertical blur PostProcess id in the pipeline
  57935. */
  57936. SSAOBlurVRenderEffect: string;
  57937. /**
  57938. * @ignore
  57939. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57940. */
  57941. SSAOCombineRenderEffect: string;
  57942. /**
  57943. * The output strength of the SSAO post-process. Default value is 1.0.
  57944. */
  57945. totalStrength: number;
  57946. /**
  57947. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57948. */
  57949. maxZ: number;
  57950. /**
  57951. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57952. */
  57953. minZAspect: number;
  57954. private _samples;
  57955. /**
  57956. * Number of samples used for the SSAO calculations. Default value is 8
  57957. */
  57958. samples: number;
  57959. private _textureSamples;
  57960. /**
  57961. * Number of samples to use for antialiasing
  57962. */
  57963. textureSamples: number;
  57964. /**
  57965. * Ratio object used for SSAO ratio and blur ratio
  57966. */
  57967. private _ratio;
  57968. /**
  57969. * Dynamically generated sphere sampler.
  57970. */
  57971. private _sampleSphere;
  57972. /**
  57973. * Blur filter offsets
  57974. */
  57975. private _samplerOffsets;
  57976. private _expensiveBlur;
  57977. /**
  57978. * If bilateral blur should be used
  57979. */
  57980. expensiveBlur: boolean;
  57981. /**
  57982. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57983. */
  57984. radius: number;
  57985. /**
  57986. * The base color of the SSAO post-process
  57987. * The final result is "base + ssao" between [0, 1]
  57988. */
  57989. base: number;
  57990. /**
  57991. * Support test.
  57992. */
  57993. static readonly IsSupported: boolean;
  57994. private _scene;
  57995. private _depthTexture;
  57996. private _normalTexture;
  57997. private _randomTexture;
  57998. private _originalColorPostProcess;
  57999. private _ssaoPostProcess;
  58000. private _blurHPostProcess;
  58001. private _blurVPostProcess;
  58002. private _ssaoCombinePostProcess;
  58003. private _firstUpdate;
  58004. /**
  58005. * Gets active scene
  58006. */
  58007. readonly scene: Scene;
  58008. /**
  58009. * @constructor
  58010. * @param name The rendering pipeline name
  58011. * @param scene The scene linked to this pipeline
  58012. * @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 }
  58013. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58014. */
  58015. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58016. /**
  58017. * Get the class name
  58018. * @returns "SSAO2RenderingPipeline"
  58019. */
  58020. getClassName(): string;
  58021. /**
  58022. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58023. */
  58024. dispose(disableGeometryBufferRenderer?: boolean): void;
  58025. private _createBlurPostProcess;
  58026. /** @hidden */
  58027. _rebuild(): void;
  58028. private _bits;
  58029. private _radicalInverse_VdC;
  58030. private _hammersley;
  58031. private _hemisphereSample_uniform;
  58032. private _generateHemisphere;
  58033. private _createSSAOPostProcess;
  58034. private _createSSAOCombinePostProcess;
  58035. private _createRandomTexture;
  58036. /**
  58037. * Serialize the rendering pipeline (Used when exporting)
  58038. * @returns the serialized object
  58039. */
  58040. serialize(): any;
  58041. /**
  58042. * Parse the serialized pipeline
  58043. * @param source Source pipeline.
  58044. * @param scene The scene to load the pipeline to.
  58045. * @param rootUrl The URL of the serialized pipeline.
  58046. * @returns An instantiated pipeline from the serialized object.
  58047. */
  58048. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58049. }
  58050. }
  58051. declare module BABYLON {
  58052. /** @hidden */
  58053. export var ssaoPixelShader: {
  58054. name: string;
  58055. shader: string;
  58056. };
  58057. }
  58058. declare module BABYLON {
  58059. /**
  58060. * Render pipeline to produce ssao effect
  58061. */
  58062. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58063. /**
  58064. * @ignore
  58065. * The PassPostProcess id in the pipeline that contains the original scene color
  58066. */
  58067. SSAOOriginalSceneColorEffect: string;
  58068. /**
  58069. * @ignore
  58070. * The SSAO PostProcess id in the pipeline
  58071. */
  58072. SSAORenderEffect: string;
  58073. /**
  58074. * @ignore
  58075. * The horizontal blur PostProcess id in the pipeline
  58076. */
  58077. SSAOBlurHRenderEffect: string;
  58078. /**
  58079. * @ignore
  58080. * The vertical blur PostProcess id in the pipeline
  58081. */
  58082. SSAOBlurVRenderEffect: string;
  58083. /**
  58084. * @ignore
  58085. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58086. */
  58087. SSAOCombineRenderEffect: string;
  58088. /**
  58089. * The output strength of the SSAO post-process. Default value is 1.0.
  58090. */
  58091. totalStrength: number;
  58092. /**
  58093. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58094. */
  58095. radius: number;
  58096. /**
  58097. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58098. * Must not be equal to fallOff and superior to fallOff.
  58099. * Default value is 0.0075
  58100. */
  58101. area: number;
  58102. /**
  58103. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58104. * Must not be equal to area and inferior to area.
  58105. * Default value is 0.000001
  58106. */
  58107. fallOff: number;
  58108. /**
  58109. * The base color of the SSAO post-process
  58110. * The final result is "base + ssao" between [0, 1]
  58111. */
  58112. base: number;
  58113. private _scene;
  58114. private _depthTexture;
  58115. private _randomTexture;
  58116. private _originalColorPostProcess;
  58117. private _ssaoPostProcess;
  58118. private _blurHPostProcess;
  58119. private _blurVPostProcess;
  58120. private _ssaoCombinePostProcess;
  58121. private _firstUpdate;
  58122. /**
  58123. * Gets active scene
  58124. */
  58125. readonly scene: Scene;
  58126. /**
  58127. * @constructor
  58128. * @param name - The rendering pipeline name
  58129. * @param scene - The scene linked to this pipeline
  58130. * @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 }
  58131. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58132. */
  58133. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58134. /**
  58135. * Get the class name
  58136. * @returns "SSAORenderingPipeline"
  58137. */
  58138. getClassName(): string;
  58139. /**
  58140. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58141. */
  58142. dispose(disableDepthRender?: boolean): void;
  58143. private _createBlurPostProcess;
  58144. /** @hidden */
  58145. _rebuild(): void;
  58146. private _createSSAOPostProcess;
  58147. private _createSSAOCombinePostProcess;
  58148. private _createRandomTexture;
  58149. }
  58150. }
  58151. declare module BABYLON {
  58152. /** @hidden */
  58153. export var standardPixelShader: {
  58154. name: string;
  58155. shader: string;
  58156. };
  58157. }
  58158. declare module BABYLON {
  58159. /**
  58160. * Standard rendering pipeline
  58161. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58162. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58163. */
  58164. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58165. /**
  58166. * Public members
  58167. */
  58168. /**
  58169. * Post-process which contains the original scene color before the pipeline applies all the effects
  58170. */
  58171. originalPostProcess: Nullable<PostProcess>;
  58172. /**
  58173. * Post-process used to down scale an image x4
  58174. */
  58175. downSampleX4PostProcess: Nullable<PostProcess>;
  58176. /**
  58177. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58178. */
  58179. brightPassPostProcess: Nullable<PostProcess>;
  58180. /**
  58181. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58182. */
  58183. blurHPostProcesses: PostProcess[];
  58184. /**
  58185. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58186. */
  58187. blurVPostProcesses: PostProcess[];
  58188. /**
  58189. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58190. */
  58191. textureAdderPostProcess: Nullable<PostProcess>;
  58192. /**
  58193. * Post-process used to create volumetric lighting effect
  58194. */
  58195. volumetricLightPostProcess: Nullable<PostProcess>;
  58196. /**
  58197. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58198. */
  58199. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58200. /**
  58201. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58202. */
  58203. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58204. /**
  58205. * Post-process used to merge the volumetric light effect and the real scene color
  58206. */
  58207. volumetricLightMergePostProces: Nullable<PostProcess>;
  58208. /**
  58209. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58210. */
  58211. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58212. /**
  58213. * Base post-process used to calculate the average luminance of the final image for HDR
  58214. */
  58215. luminancePostProcess: Nullable<PostProcess>;
  58216. /**
  58217. * Post-processes used to create down sample post-processes in order to get
  58218. * the average luminance of the final image for HDR
  58219. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58220. */
  58221. luminanceDownSamplePostProcesses: PostProcess[];
  58222. /**
  58223. * Post-process used to create a HDR effect (light adaptation)
  58224. */
  58225. hdrPostProcess: Nullable<PostProcess>;
  58226. /**
  58227. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58228. */
  58229. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58230. /**
  58231. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58232. */
  58233. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58234. /**
  58235. * Post-process used to merge the final HDR post-process and the real scene color
  58236. */
  58237. hdrFinalPostProcess: Nullable<PostProcess>;
  58238. /**
  58239. * Post-process used to create a lens flare effect
  58240. */
  58241. lensFlarePostProcess: Nullable<PostProcess>;
  58242. /**
  58243. * Post-process that merges the result of the lens flare post-process and the real scene color
  58244. */
  58245. lensFlareComposePostProcess: Nullable<PostProcess>;
  58246. /**
  58247. * Post-process used to create a motion blur effect
  58248. */
  58249. motionBlurPostProcess: Nullable<PostProcess>;
  58250. /**
  58251. * Post-process used to create a depth of field effect
  58252. */
  58253. depthOfFieldPostProcess: Nullable<PostProcess>;
  58254. /**
  58255. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58256. */
  58257. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58258. /**
  58259. * Represents the brightness threshold in order to configure the illuminated surfaces
  58260. */
  58261. brightThreshold: number;
  58262. /**
  58263. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58264. */
  58265. blurWidth: number;
  58266. /**
  58267. * Sets if the blur for highlighted surfaces must be only horizontal
  58268. */
  58269. horizontalBlur: boolean;
  58270. /**
  58271. * Gets the overall exposure used by the pipeline
  58272. */
  58273. /**
  58274. * Sets the overall exposure used by the pipeline
  58275. */
  58276. exposure: number;
  58277. /**
  58278. * Texture used typically to simulate "dirty" on camera lens
  58279. */
  58280. lensTexture: Nullable<Texture>;
  58281. /**
  58282. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58283. */
  58284. volumetricLightCoefficient: number;
  58285. /**
  58286. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58287. */
  58288. volumetricLightPower: number;
  58289. /**
  58290. * Used the set the blur intensity to smooth the volumetric lights
  58291. */
  58292. volumetricLightBlurScale: number;
  58293. /**
  58294. * Light (spot or directional) used to generate the volumetric lights rays
  58295. * The source light must have a shadow generate so the pipeline can get its
  58296. * depth map
  58297. */
  58298. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58299. /**
  58300. * For eye adaptation, represents the minimum luminance the eye can see
  58301. */
  58302. hdrMinimumLuminance: number;
  58303. /**
  58304. * For eye adaptation, represents the decrease luminance speed
  58305. */
  58306. hdrDecreaseRate: number;
  58307. /**
  58308. * For eye adaptation, represents the increase luminance speed
  58309. */
  58310. hdrIncreaseRate: number;
  58311. /**
  58312. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58313. */
  58314. /**
  58315. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58316. */
  58317. hdrAutoExposure: boolean;
  58318. /**
  58319. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58320. */
  58321. lensColorTexture: Nullable<Texture>;
  58322. /**
  58323. * The overall strengh for the lens flare effect
  58324. */
  58325. lensFlareStrength: number;
  58326. /**
  58327. * Dispersion coefficient for lens flare ghosts
  58328. */
  58329. lensFlareGhostDispersal: number;
  58330. /**
  58331. * Main lens flare halo width
  58332. */
  58333. lensFlareHaloWidth: number;
  58334. /**
  58335. * Based on the lens distortion effect, defines how much the lens flare result
  58336. * is distorted
  58337. */
  58338. lensFlareDistortionStrength: number;
  58339. /**
  58340. * Lens star texture must be used to simulate rays on the flares and is available
  58341. * in the documentation
  58342. */
  58343. lensStarTexture: Nullable<Texture>;
  58344. /**
  58345. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58346. * flare effect by taking account of the dirt texture
  58347. */
  58348. lensFlareDirtTexture: Nullable<Texture>;
  58349. /**
  58350. * Represents the focal length for the depth of field effect
  58351. */
  58352. depthOfFieldDistance: number;
  58353. /**
  58354. * Represents the blur intensity for the blurred part of the depth of field effect
  58355. */
  58356. depthOfFieldBlurWidth: number;
  58357. /**
  58358. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58359. */
  58360. /**
  58361. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58362. */
  58363. motionStrength: number;
  58364. /**
  58365. * Gets wether or not the motion blur post-process is object based or screen based.
  58366. */
  58367. /**
  58368. * Sets wether or not the motion blur post-process should be object based or screen based
  58369. */
  58370. objectBasedMotionBlur: boolean;
  58371. /**
  58372. * List of animations for the pipeline (IAnimatable implementation)
  58373. */
  58374. animations: Animation[];
  58375. /**
  58376. * Private members
  58377. */
  58378. private _scene;
  58379. private _currentDepthOfFieldSource;
  58380. private _basePostProcess;
  58381. private _fixedExposure;
  58382. private _currentExposure;
  58383. private _hdrAutoExposure;
  58384. private _hdrCurrentLuminance;
  58385. private _motionStrength;
  58386. private _isObjectBasedMotionBlur;
  58387. private _floatTextureType;
  58388. private _ratio;
  58389. private _bloomEnabled;
  58390. private _depthOfFieldEnabled;
  58391. private _vlsEnabled;
  58392. private _lensFlareEnabled;
  58393. private _hdrEnabled;
  58394. private _motionBlurEnabled;
  58395. private _fxaaEnabled;
  58396. private _motionBlurSamples;
  58397. private _volumetricLightStepsCount;
  58398. private _samples;
  58399. /**
  58400. * @ignore
  58401. * Specifies if the bloom pipeline is enabled
  58402. */
  58403. BloomEnabled: boolean;
  58404. /**
  58405. * @ignore
  58406. * Specifies if the depth of field pipeline is enabed
  58407. */
  58408. DepthOfFieldEnabled: boolean;
  58409. /**
  58410. * @ignore
  58411. * Specifies if the lens flare pipeline is enabed
  58412. */
  58413. LensFlareEnabled: boolean;
  58414. /**
  58415. * @ignore
  58416. * Specifies if the HDR pipeline is enabled
  58417. */
  58418. HDREnabled: boolean;
  58419. /**
  58420. * @ignore
  58421. * Specifies if the volumetric lights scattering effect is enabled
  58422. */
  58423. VLSEnabled: boolean;
  58424. /**
  58425. * @ignore
  58426. * Specifies if the motion blur effect is enabled
  58427. */
  58428. MotionBlurEnabled: boolean;
  58429. /**
  58430. * Specifies if anti-aliasing is enabled
  58431. */
  58432. fxaaEnabled: boolean;
  58433. /**
  58434. * Specifies the number of steps used to calculate the volumetric lights
  58435. * Typically in interval [50, 200]
  58436. */
  58437. volumetricLightStepsCount: number;
  58438. /**
  58439. * Specifies the number of samples used for the motion blur effect
  58440. * Typically in interval [16, 64]
  58441. */
  58442. motionBlurSamples: number;
  58443. /**
  58444. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58445. */
  58446. samples: number;
  58447. /**
  58448. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58449. * @constructor
  58450. * @param name The rendering pipeline name
  58451. * @param scene The scene linked to this pipeline
  58452. * @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)
  58453. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58454. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58455. */
  58456. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58457. private _buildPipeline;
  58458. private _createDownSampleX4PostProcess;
  58459. private _createBrightPassPostProcess;
  58460. private _createBlurPostProcesses;
  58461. private _createTextureAdderPostProcess;
  58462. private _createVolumetricLightPostProcess;
  58463. private _createLuminancePostProcesses;
  58464. private _createHdrPostProcess;
  58465. private _createLensFlarePostProcess;
  58466. private _createDepthOfFieldPostProcess;
  58467. private _createMotionBlurPostProcess;
  58468. private _getDepthTexture;
  58469. private _disposePostProcesses;
  58470. /**
  58471. * Dispose of the pipeline and stop all post processes
  58472. */
  58473. dispose(): void;
  58474. /**
  58475. * Serialize the rendering pipeline (Used when exporting)
  58476. * @returns the serialized object
  58477. */
  58478. serialize(): any;
  58479. /**
  58480. * Parse the serialized pipeline
  58481. * @param source Source pipeline.
  58482. * @param scene The scene to load the pipeline to.
  58483. * @param rootUrl The URL of the serialized pipeline.
  58484. * @returns An instantiated pipeline from the serialized object.
  58485. */
  58486. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58487. /**
  58488. * Luminance steps
  58489. */
  58490. static LuminanceSteps: number;
  58491. }
  58492. }
  58493. declare module BABYLON {
  58494. /** @hidden */
  58495. export var tonemapPixelShader: {
  58496. name: string;
  58497. shader: string;
  58498. };
  58499. }
  58500. declare module BABYLON {
  58501. /** Defines operator used for tonemapping */
  58502. export enum TonemappingOperator {
  58503. /** Hable */
  58504. Hable = 0,
  58505. /** Reinhard */
  58506. Reinhard = 1,
  58507. /** HejiDawson */
  58508. HejiDawson = 2,
  58509. /** Photographic */
  58510. Photographic = 3
  58511. }
  58512. /**
  58513. * Defines a post process to apply tone mapping
  58514. */
  58515. export class TonemapPostProcess extends PostProcess {
  58516. private _operator;
  58517. /** Defines the required exposure adjustement */
  58518. exposureAdjustment: number;
  58519. /**
  58520. * Creates a new TonemapPostProcess
  58521. * @param name defines the name of the postprocess
  58522. * @param _operator defines the operator to use
  58523. * @param exposureAdjustment defines the required exposure adjustement
  58524. * @param camera defines the camera to use (can be null)
  58525. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58526. * @param engine defines the hosting engine (can be ignore if camera is set)
  58527. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58528. */
  58529. constructor(name: string, _operator: TonemappingOperator,
  58530. /** Defines the required exposure adjustement */
  58531. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58532. }
  58533. }
  58534. declare module BABYLON {
  58535. /** @hidden */
  58536. export var depthVertexShader: {
  58537. name: string;
  58538. shader: string;
  58539. };
  58540. }
  58541. declare module BABYLON {
  58542. /** @hidden */
  58543. export var volumetricLightScatteringPixelShader: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module BABYLON {
  58549. /** @hidden */
  58550. export var volumetricLightScatteringPassPixelShader: {
  58551. name: string;
  58552. shader: string;
  58553. };
  58554. }
  58555. declare module BABYLON {
  58556. /**
  58557. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58558. */
  58559. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58560. private _volumetricLightScatteringPass;
  58561. private _volumetricLightScatteringRTT;
  58562. private _viewPort;
  58563. private _screenCoordinates;
  58564. private _cachedDefines;
  58565. /**
  58566. * If not undefined, the mesh position is computed from the attached node position
  58567. */
  58568. attachedNode: {
  58569. position: Vector3;
  58570. };
  58571. /**
  58572. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58573. */
  58574. customMeshPosition: Vector3;
  58575. /**
  58576. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58577. */
  58578. useCustomMeshPosition: boolean;
  58579. /**
  58580. * If the post-process should inverse the light scattering direction
  58581. */
  58582. invert: boolean;
  58583. /**
  58584. * The internal mesh used by the post-process
  58585. */
  58586. mesh: Mesh;
  58587. /**
  58588. * @hidden
  58589. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58590. */
  58591. useDiffuseColor: boolean;
  58592. /**
  58593. * Array containing the excluded meshes not rendered in the internal pass
  58594. */
  58595. excludedMeshes: AbstractMesh[];
  58596. /**
  58597. * Controls the overall intensity of the post-process
  58598. */
  58599. exposure: number;
  58600. /**
  58601. * Dissipates each sample's contribution in range [0, 1]
  58602. */
  58603. decay: number;
  58604. /**
  58605. * Controls the overall intensity of each sample
  58606. */
  58607. weight: number;
  58608. /**
  58609. * Controls the density of each sample
  58610. */
  58611. density: number;
  58612. /**
  58613. * @constructor
  58614. * @param name The post-process name
  58615. * @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)
  58616. * @param camera The camera that the post-process will be attached to
  58617. * @param mesh The mesh used to create the light scattering
  58618. * @param samples The post-process quality, default 100
  58619. * @param samplingModeThe post-process filtering mode
  58620. * @param engine The babylon engine
  58621. * @param reusable If the post-process is reusable
  58622. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58623. */
  58624. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58625. /**
  58626. * Returns the string "VolumetricLightScatteringPostProcess"
  58627. * @returns "VolumetricLightScatteringPostProcess"
  58628. */
  58629. getClassName(): string;
  58630. private _isReady;
  58631. /**
  58632. * Sets the new light position for light scattering effect
  58633. * @param position The new custom light position
  58634. */
  58635. setCustomMeshPosition(position: Vector3): void;
  58636. /**
  58637. * Returns the light position for light scattering effect
  58638. * @return Vector3 The custom light position
  58639. */
  58640. getCustomMeshPosition(): Vector3;
  58641. /**
  58642. * Disposes the internal assets and detaches the post-process from the camera
  58643. */
  58644. dispose(camera: Camera): void;
  58645. /**
  58646. * Returns the render target texture used by the post-process
  58647. * @return the render target texture used by the post-process
  58648. */
  58649. getPass(): RenderTargetTexture;
  58650. private _meshExcluded;
  58651. private _createPass;
  58652. private _updateMeshScreenCoordinates;
  58653. /**
  58654. * Creates a default mesh for the Volumeric Light Scattering post-process
  58655. * @param name The mesh name
  58656. * @param scene The scene where to create the mesh
  58657. * @return the default mesh
  58658. */
  58659. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58660. }
  58661. }
  58662. declare module BABYLON {
  58663. interface Scene {
  58664. /** @hidden (Backing field) */
  58665. _boundingBoxRenderer: BoundingBoxRenderer;
  58666. /** @hidden (Backing field) */
  58667. _forceShowBoundingBoxes: boolean;
  58668. /**
  58669. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58670. */
  58671. forceShowBoundingBoxes: boolean;
  58672. /**
  58673. * Gets the bounding box renderer associated with the scene
  58674. * @returns a BoundingBoxRenderer
  58675. */
  58676. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58677. }
  58678. interface AbstractMesh {
  58679. /** @hidden (Backing field) */
  58680. _showBoundingBox: boolean;
  58681. /**
  58682. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58683. */
  58684. showBoundingBox: boolean;
  58685. }
  58686. /**
  58687. * Component responsible of rendering the bounding box of the meshes in a scene.
  58688. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58689. */
  58690. export class BoundingBoxRenderer implements ISceneComponent {
  58691. /**
  58692. * The component name helpfull to identify the component in the list of scene components.
  58693. */
  58694. readonly name: string;
  58695. /**
  58696. * The scene the component belongs to.
  58697. */
  58698. scene: Scene;
  58699. /**
  58700. * Color of the bounding box lines placed in front of an object
  58701. */
  58702. frontColor: Color3;
  58703. /**
  58704. * Color of the bounding box lines placed behind an object
  58705. */
  58706. backColor: Color3;
  58707. /**
  58708. * Defines if the renderer should show the back lines or not
  58709. */
  58710. showBackLines: boolean;
  58711. /**
  58712. * @hidden
  58713. */
  58714. renderList: SmartArray<BoundingBox>;
  58715. private _colorShader;
  58716. private _vertexBuffers;
  58717. private _indexBuffer;
  58718. private _fillIndexBuffer;
  58719. private _fillIndexData;
  58720. /**
  58721. * Instantiates a new bounding box renderer in a scene.
  58722. * @param scene the scene the renderer renders in
  58723. */
  58724. constructor(scene: Scene);
  58725. /**
  58726. * Registers the component in a given scene
  58727. */
  58728. register(): void;
  58729. private _evaluateSubMesh;
  58730. private _activeMesh;
  58731. private _prepareRessources;
  58732. private _createIndexBuffer;
  58733. /**
  58734. * Rebuilds the elements related to this component in case of
  58735. * context lost for instance.
  58736. */
  58737. rebuild(): void;
  58738. /**
  58739. * @hidden
  58740. */
  58741. reset(): void;
  58742. /**
  58743. * Render the bounding boxes of a specific rendering group
  58744. * @param renderingGroupId defines the rendering group to render
  58745. */
  58746. render(renderingGroupId: number): void;
  58747. /**
  58748. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58749. * @param mesh Define the mesh to render the occlusion bounding box for
  58750. */
  58751. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58752. /**
  58753. * Dispose and release the resources attached to this renderer.
  58754. */
  58755. dispose(): void;
  58756. }
  58757. }
  58758. declare module BABYLON {
  58759. /** @hidden */
  58760. export var depthPixelShader: {
  58761. name: string;
  58762. shader: string;
  58763. };
  58764. }
  58765. declare module BABYLON {
  58766. /**
  58767. * This represents a depth renderer in Babylon.
  58768. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58769. */
  58770. export class DepthRenderer {
  58771. private _scene;
  58772. private _depthMap;
  58773. private _effect;
  58774. private readonly _storeNonLinearDepth;
  58775. private readonly _clearColor;
  58776. /** Get if the depth renderer is using packed depth or not */
  58777. readonly isPacked: boolean;
  58778. private _cachedDefines;
  58779. private _camera;
  58780. /**
  58781. * Specifiess that the depth renderer will only be used within
  58782. * the camera it is created for.
  58783. * This can help forcing its rendering during the camera processing.
  58784. */
  58785. useOnlyInActiveCamera: boolean;
  58786. /** @hidden */
  58787. static _SceneComponentInitialization: (scene: Scene) => void;
  58788. /**
  58789. * Instantiates a depth renderer
  58790. * @param scene The scene the renderer belongs to
  58791. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58792. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58793. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58794. */
  58795. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58796. /**
  58797. * Creates the depth rendering effect and checks if the effect is ready.
  58798. * @param subMesh The submesh to be used to render the depth map of
  58799. * @param useInstances If multiple world instances should be used
  58800. * @returns if the depth renderer is ready to render the depth map
  58801. */
  58802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58803. /**
  58804. * Gets the texture which the depth map will be written to.
  58805. * @returns The depth map texture
  58806. */
  58807. getDepthMap(): RenderTargetTexture;
  58808. /**
  58809. * Disposes of the depth renderer.
  58810. */
  58811. dispose(): void;
  58812. }
  58813. }
  58814. declare module BABYLON {
  58815. interface Scene {
  58816. /** @hidden (Backing field) */
  58817. _depthRenderer: {
  58818. [id: string]: DepthRenderer;
  58819. };
  58820. /**
  58821. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58822. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58823. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58824. * @returns the created depth renderer
  58825. */
  58826. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58827. /**
  58828. * Disables a depth renderer for a given camera
  58829. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58830. */
  58831. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58832. }
  58833. /**
  58834. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58835. * in several rendering techniques.
  58836. */
  58837. export class DepthRendererSceneComponent implements ISceneComponent {
  58838. /**
  58839. * The component name helpfull to identify the component in the list of scene components.
  58840. */
  58841. readonly name: string;
  58842. /**
  58843. * The scene the component belongs to.
  58844. */
  58845. scene: Scene;
  58846. /**
  58847. * Creates a new instance of the component for the given scene
  58848. * @param scene Defines the scene to register the component in
  58849. */
  58850. constructor(scene: Scene);
  58851. /**
  58852. * Registers the component in a given scene
  58853. */
  58854. register(): void;
  58855. /**
  58856. * Rebuilds the elements related to this component in case of
  58857. * context lost for instance.
  58858. */
  58859. rebuild(): void;
  58860. /**
  58861. * Disposes the component and the associated ressources
  58862. */
  58863. dispose(): void;
  58864. private _gatherRenderTargets;
  58865. private _gatherActiveCameraRenderTargets;
  58866. }
  58867. }
  58868. declare module BABYLON {
  58869. /** @hidden */
  58870. export var outlinePixelShader: {
  58871. name: string;
  58872. shader: string;
  58873. };
  58874. }
  58875. declare module BABYLON {
  58876. /** @hidden */
  58877. export var outlineVertexShader: {
  58878. name: string;
  58879. shader: string;
  58880. };
  58881. }
  58882. declare module BABYLON {
  58883. interface Scene {
  58884. /** @hidden */
  58885. _outlineRenderer: OutlineRenderer;
  58886. /**
  58887. * Gets the outline renderer associated with the scene
  58888. * @returns a OutlineRenderer
  58889. */
  58890. getOutlineRenderer(): OutlineRenderer;
  58891. }
  58892. interface AbstractMesh {
  58893. /** @hidden (Backing field) */
  58894. _renderOutline: boolean;
  58895. /**
  58896. * Gets or sets a boolean indicating if the outline must be rendered as well
  58897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58898. */
  58899. renderOutline: boolean;
  58900. /** @hidden (Backing field) */
  58901. _renderOverlay: boolean;
  58902. /**
  58903. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58904. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58905. */
  58906. renderOverlay: boolean;
  58907. }
  58908. /**
  58909. * This class is responsible to draw bothe outline/overlay of meshes.
  58910. * It should not be used directly but through the available method on mesh.
  58911. */
  58912. export class OutlineRenderer implements ISceneComponent {
  58913. /**
  58914. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58915. */
  58916. private static _StencilReference;
  58917. /**
  58918. * The name of the component. Each component must have a unique name.
  58919. */
  58920. name: string;
  58921. /**
  58922. * The scene the component belongs to.
  58923. */
  58924. scene: Scene;
  58925. /**
  58926. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58927. */
  58928. zOffset: number;
  58929. private _engine;
  58930. private _effect;
  58931. private _cachedDefines;
  58932. private _savedDepthWrite;
  58933. /**
  58934. * Instantiates a new outline renderer. (There could be only one per scene).
  58935. * @param scene Defines the scene it belongs to
  58936. */
  58937. constructor(scene: Scene);
  58938. /**
  58939. * Register the component to one instance of a scene.
  58940. */
  58941. register(): void;
  58942. /**
  58943. * Rebuilds the elements related to this component in case of
  58944. * context lost for instance.
  58945. */
  58946. rebuild(): void;
  58947. /**
  58948. * Disposes the component and the associated ressources.
  58949. */
  58950. dispose(): void;
  58951. /**
  58952. * Renders the outline in the canvas.
  58953. * @param subMesh Defines the sumesh to render
  58954. * @param batch Defines the batch of meshes in case of instances
  58955. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58956. */
  58957. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58958. /**
  58959. * Returns whether or not the outline renderer is ready for a given submesh.
  58960. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58961. * @param subMesh Defines the submesh to check readyness for
  58962. * @param useInstances Defines wheter wee are trying to render instances or not
  58963. * @returns true if ready otherwise false
  58964. */
  58965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58966. private _beforeRenderingMesh;
  58967. private _afterRenderingMesh;
  58968. }
  58969. }
  58970. declare module BABYLON {
  58971. /**
  58972. * Defines the list of states available for a task inside a AssetsManager
  58973. */
  58974. export enum AssetTaskState {
  58975. /**
  58976. * Initialization
  58977. */
  58978. INIT = 0,
  58979. /**
  58980. * Running
  58981. */
  58982. RUNNING = 1,
  58983. /**
  58984. * Done
  58985. */
  58986. DONE = 2,
  58987. /**
  58988. * Error
  58989. */
  58990. ERROR = 3
  58991. }
  58992. /**
  58993. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58994. */
  58995. export abstract class AbstractAssetTask {
  58996. /**
  58997. * Task name
  58998. */ name: string;
  58999. /**
  59000. * Callback called when the task is successful
  59001. */
  59002. onSuccess: (task: any) => void;
  59003. /**
  59004. * Callback called when the task is not successful
  59005. */
  59006. onError: (task: any, message?: string, exception?: any) => void;
  59007. /**
  59008. * Creates a new AssetsManager
  59009. * @param name defines the name of the task
  59010. */
  59011. constructor(
  59012. /**
  59013. * Task name
  59014. */ name: string);
  59015. private _isCompleted;
  59016. private _taskState;
  59017. private _errorObject;
  59018. /**
  59019. * Get if the task is completed
  59020. */
  59021. readonly isCompleted: boolean;
  59022. /**
  59023. * Gets the current state of the task
  59024. */
  59025. readonly taskState: AssetTaskState;
  59026. /**
  59027. * Gets the current error object (if task is in error)
  59028. */
  59029. readonly errorObject: {
  59030. message?: string;
  59031. exception?: any;
  59032. };
  59033. /**
  59034. * Internal only
  59035. * @hidden
  59036. */
  59037. _setErrorObject(message?: string, exception?: any): void;
  59038. /**
  59039. * Execute the current task
  59040. * @param scene defines the scene where you want your assets to be loaded
  59041. * @param onSuccess is a callback called when the task is successfully executed
  59042. * @param onError is a callback called if an error occurs
  59043. */
  59044. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59045. /**
  59046. * Execute the current task
  59047. * @param scene defines the scene where you want your assets to be loaded
  59048. * @param onSuccess is a callback called when the task is successfully executed
  59049. * @param onError is a callback called if an error occurs
  59050. */
  59051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59052. /**
  59053. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59054. * This can be used with failed tasks that have the reason for failure fixed.
  59055. */
  59056. reset(): void;
  59057. private onErrorCallback;
  59058. private onDoneCallback;
  59059. }
  59060. /**
  59061. * Define the interface used by progress events raised during assets loading
  59062. */
  59063. export interface IAssetsProgressEvent {
  59064. /**
  59065. * Defines the number of remaining tasks to process
  59066. */
  59067. remainingCount: number;
  59068. /**
  59069. * Defines the total number of tasks
  59070. */
  59071. totalCount: number;
  59072. /**
  59073. * Defines the task that was just processed
  59074. */
  59075. task: AbstractAssetTask;
  59076. }
  59077. /**
  59078. * Class used to share progress information about assets loading
  59079. */
  59080. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59081. /**
  59082. * Defines the number of remaining tasks to process
  59083. */
  59084. remainingCount: number;
  59085. /**
  59086. * Defines the total number of tasks
  59087. */
  59088. totalCount: number;
  59089. /**
  59090. * Defines the task that was just processed
  59091. */
  59092. task: AbstractAssetTask;
  59093. /**
  59094. * Creates a AssetsProgressEvent
  59095. * @param remainingCount defines the number of remaining tasks to process
  59096. * @param totalCount defines the total number of tasks
  59097. * @param task defines the task that was just processed
  59098. */
  59099. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59100. }
  59101. /**
  59102. * Define a task used by AssetsManager to load meshes
  59103. */
  59104. export class MeshAssetTask extends AbstractAssetTask {
  59105. /**
  59106. * Defines the name of the task
  59107. */
  59108. name: string;
  59109. /**
  59110. * Defines the list of mesh's names you want to load
  59111. */
  59112. meshesNames: any;
  59113. /**
  59114. * Defines the root url to use as a base to load your meshes and associated resources
  59115. */
  59116. rootUrl: string;
  59117. /**
  59118. * Defines the filename of the scene to load from
  59119. */
  59120. sceneFilename: string;
  59121. /**
  59122. * Gets the list of loaded meshes
  59123. */
  59124. loadedMeshes: Array<AbstractMesh>;
  59125. /**
  59126. * Gets the list of loaded particle systems
  59127. */
  59128. loadedParticleSystems: Array<IParticleSystem>;
  59129. /**
  59130. * Gets the list of loaded skeletons
  59131. */
  59132. loadedSkeletons: Array<Skeleton>;
  59133. /**
  59134. * Gets the list of loaded animation groups
  59135. */
  59136. loadedAnimationGroups: Array<AnimationGroup>;
  59137. /**
  59138. * Callback called when the task is successful
  59139. */
  59140. onSuccess: (task: MeshAssetTask) => void;
  59141. /**
  59142. * Callback called when the task is successful
  59143. */
  59144. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59145. /**
  59146. * Creates a new MeshAssetTask
  59147. * @param name defines the name of the task
  59148. * @param meshesNames defines the list of mesh's names you want to load
  59149. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59150. * @param sceneFilename defines the filename of the scene to load from
  59151. */
  59152. constructor(
  59153. /**
  59154. * Defines the name of the task
  59155. */
  59156. name: string,
  59157. /**
  59158. * Defines the list of mesh's names you want to load
  59159. */
  59160. meshesNames: any,
  59161. /**
  59162. * Defines the root url to use as a base to load your meshes and associated resources
  59163. */
  59164. rootUrl: string,
  59165. /**
  59166. * Defines the filename of the scene to load from
  59167. */
  59168. sceneFilename: string);
  59169. /**
  59170. * Execute the current task
  59171. * @param scene defines the scene where you want your assets to be loaded
  59172. * @param onSuccess is a callback called when the task is successfully executed
  59173. * @param onError is a callback called if an error occurs
  59174. */
  59175. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59176. }
  59177. /**
  59178. * Define a task used by AssetsManager to load text content
  59179. */
  59180. export class TextFileAssetTask extends AbstractAssetTask {
  59181. /**
  59182. * Defines the name of the task
  59183. */
  59184. name: string;
  59185. /**
  59186. * Defines the location of the file to load
  59187. */
  59188. url: string;
  59189. /**
  59190. * Gets the loaded text string
  59191. */
  59192. text: string;
  59193. /**
  59194. * Callback called when the task is successful
  59195. */
  59196. onSuccess: (task: TextFileAssetTask) => void;
  59197. /**
  59198. * Callback called when the task is successful
  59199. */
  59200. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59201. /**
  59202. * Creates a new TextFileAssetTask object
  59203. * @param name defines the name of the task
  59204. * @param url defines the location of the file to load
  59205. */
  59206. constructor(
  59207. /**
  59208. * Defines the name of the task
  59209. */
  59210. name: string,
  59211. /**
  59212. * Defines the location of the file to load
  59213. */
  59214. url: string);
  59215. /**
  59216. * Execute the current task
  59217. * @param scene defines the scene where you want your assets to be loaded
  59218. * @param onSuccess is a callback called when the task is successfully executed
  59219. * @param onError is a callback called if an error occurs
  59220. */
  59221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59222. }
  59223. /**
  59224. * Define a task used by AssetsManager to load binary data
  59225. */
  59226. export class BinaryFileAssetTask extends AbstractAssetTask {
  59227. /**
  59228. * Defines the name of the task
  59229. */
  59230. name: string;
  59231. /**
  59232. * Defines the location of the file to load
  59233. */
  59234. url: string;
  59235. /**
  59236. * Gets the lodaded data (as an array buffer)
  59237. */
  59238. data: ArrayBuffer;
  59239. /**
  59240. * Callback called when the task is successful
  59241. */
  59242. onSuccess: (task: BinaryFileAssetTask) => void;
  59243. /**
  59244. * Callback called when the task is successful
  59245. */
  59246. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59247. /**
  59248. * Creates a new BinaryFileAssetTask object
  59249. * @param name defines the name of the new task
  59250. * @param url defines the location of the file to load
  59251. */
  59252. constructor(
  59253. /**
  59254. * Defines the name of the task
  59255. */
  59256. name: string,
  59257. /**
  59258. * Defines the location of the file to load
  59259. */
  59260. url: string);
  59261. /**
  59262. * Execute the current task
  59263. * @param scene defines the scene where you want your assets to be loaded
  59264. * @param onSuccess is a callback called when the task is successfully executed
  59265. * @param onError is a callback called if an error occurs
  59266. */
  59267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59268. }
  59269. /**
  59270. * Define a task used by AssetsManager to load images
  59271. */
  59272. export class ImageAssetTask extends AbstractAssetTask {
  59273. /**
  59274. * Defines the name of the task
  59275. */
  59276. name: string;
  59277. /**
  59278. * Defines the location of the image to load
  59279. */
  59280. url: string;
  59281. /**
  59282. * Gets the loaded images
  59283. */
  59284. image: HTMLImageElement;
  59285. /**
  59286. * Callback called when the task is successful
  59287. */
  59288. onSuccess: (task: ImageAssetTask) => void;
  59289. /**
  59290. * Callback called when the task is successful
  59291. */
  59292. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59293. /**
  59294. * Creates a new ImageAssetTask
  59295. * @param name defines the name of the task
  59296. * @param url defines the location of the image to load
  59297. */
  59298. constructor(
  59299. /**
  59300. * Defines the name of the task
  59301. */
  59302. name: string,
  59303. /**
  59304. * Defines the location of the image to load
  59305. */
  59306. url: string);
  59307. /**
  59308. * Execute the current task
  59309. * @param scene defines the scene where you want your assets to be loaded
  59310. * @param onSuccess is a callback called when the task is successfully executed
  59311. * @param onError is a callback called if an error occurs
  59312. */
  59313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59314. }
  59315. /**
  59316. * Defines the interface used by texture loading tasks
  59317. */
  59318. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59319. /**
  59320. * Gets the loaded texture
  59321. */
  59322. texture: TEX;
  59323. }
  59324. /**
  59325. * Define a task used by AssetsManager to load 2D textures
  59326. */
  59327. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59328. /**
  59329. * Defines the name of the task
  59330. */
  59331. name: string;
  59332. /**
  59333. * Defines the location of the file to load
  59334. */
  59335. url: string;
  59336. /**
  59337. * Defines if mipmap should not be generated (default is false)
  59338. */
  59339. noMipmap?: boolean | undefined;
  59340. /**
  59341. * Defines if texture must be inverted on Y axis (default is false)
  59342. */
  59343. invertY?: boolean | undefined;
  59344. /**
  59345. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59346. */
  59347. samplingMode: number;
  59348. /**
  59349. * Gets the loaded texture
  59350. */
  59351. texture: Texture;
  59352. /**
  59353. * Callback called when the task is successful
  59354. */
  59355. onSuccess: (task: TextureAssetTask) => void;
  59356. /**
  59357. * Callback called when the task is successful
  59358. */
  59359. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59360. /**
  59361. * Creates a new TextureAssetTask object
  59362. * @param name defines the name of the task
  59363. * @param url defines the location of the file to load
  59364. * @param noMipmap defines if mipmap should not be generated (default is false)
  59365. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59366. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59367. */
  59368. constructor(
  59369. /**
  59370. * Defines the name of the task
  59371. */
  59372. name: string,
  59373. /**
  59374. * Defines the location of the file to load
  59375. */
  59376. url: string,
  59377. /**
  59378. * Defines if mipmap should not be generated (default is false)
  59379. */
  59380. noMipmap?: boolean | undefined,
  59381. /**
  59382. * Defines if texture must be inverted on Y axis (default is false)
  59383. */
  59384. invertY?: boolean | undefined,
  59385. /**
  59386. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59387. */
  59388. samplingMode?: number);
  59389. /**
  59390. * Execute the current task
  59391. * @param scene defines the scene where you want your assets to be loaded
  59392. * @param onSuccess is a callback called when the task is successfully executed
  59393. * @param onError is a callback called if an error occurs
  59394. */
  59395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59396. }
  59397. /**
  59398. * Define a task used by AssetsManager to load cube textures
  59399. */
  59400. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59401. /**
  59402. * Defines the name of the task
  59403. */
  59404. name: string;
  59405. /**
  59406. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59407. */
  59408. url: string;
  59409. /**
  59410. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59411. */
  59412. extensions?: string[] | undefined;
  59413. /**
  59414. * Defines if mipmaps should not be generated (default is false)
  59415. */
  59416. noMipmap?: boolean | undefined;
  59417. /**
  59418. * Defines the explicit list of files (undefined by default)
  59419. */
  59420. files?: string[] | undefined;
  59421. /**
  59422. * Gets the loaded texture
  59423. */
  59424. texture: CubeTexture;
  59425. /**
  59426. * Callback called when the task is successful
  59427. */
  59428. onSuccess: (task: CubeTextureAssetTask) => void;
  59429. /**
  59430. * Callback called when the task is successful
  59431. */
  59432. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59433. /**
  59434. * Creates a new CubeTextureAssetTask
  59435. * @param name defines the name of the task
  59436. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59437. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59438. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59439. * @param files defines the explicit list of files (undefined by default)
  59440. */
  59441. constructor(
  59442. /**
  59443. * Defines the name of the task
  59444. */
  59445. name: string,
  59446. /**
  59447. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59448. */
  59449. url: string,
  59450. /**
  59451. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59452. */
  59453. extensions?: string[] | undefined,
  59454. /**
  59455. * Defines if mipmaps should not be generated (default is false)
  59456. */
  59457. noMipmap?: boolean | undefined,
  59458. /**
  59459. * Defines the explicit list of files (undefined by default)
  59460. */
  59461. files?: string[] | undefined);
  59462. /**
  59463. * Execute the current task
  59464. * @param scene defines the scene where you want your assets to be loaded
  59465. * @param onSuccess is a callback called when the task is successfully executed
  59466. * @param onError is a callback called if an error occurs
  59467. */
  59468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59469. }
  59470. /**
  59471. * Define a task used by AssetsManager to load HDR cube textures
  59472. */
  59473. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59474. /**
  59475. * Defines the name of the task
  59476. */
  59477. name: string;
  59478. /**
  59479. * Defines the location of the file to load
  59480. */
  59481. url: string;
  59482. /**
  59483. * Defines the desired size (the more it increases the longer the generation will be)
  59484. */
  59485. size: number;
  59486. /**
  59487. * Defines if mipmaps should not be generated (default is false)
  59488. */
  59489. noMipmap: boolean;
  59490. /**
  59491. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59492. */
  59493. generateHarmonics: boolean;
  59494. /**
  59495. * 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)
  59496. */
  59497. gammaSpace: boolean;
  59498. /**
  59499. * Internal Use Only
  59500. */
  59501. reserved: boolean;
  59502. /**
  59503. * Gets the loaded texture
  59504. */
  59505. texture: HDRCubeTexture;
  59506. /**
  59507. * Callback called when the task is successful
  59508. */
  59509. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59510. /**
  59511. * Callback called when the task is successful
  59512. */
  59513. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59514. /**
  59515. * Creates a new HDRCubeTextureAssetTask object
  59516. * @param name defines the name of the task
  59517. * @param url defines the location of the file to load
  59518. * @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.
  59519. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59520. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59521. * @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)
  59522. * @param reserved Internal use only
  59523. */
  59524. constructor(
  59525. /**
  59526. * Defines the name of the task
  59527. */
  59528. name: string,
  59529. /**
  59530. * Defines the location of the file to load
  59531. */
  59532. url: string,
  59533. /**
  59534. * Defines the desired size (the more it increases the longer the generation will be)
  59535. */
  59536. size: number,
  59537. /**
  59538. * Defines if mipmaps should not be generated (default is false)
  59539. */
  59540. noMipmap?: boolean,
  59541. /**
  59542. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59543. */
  59544. generateHarmonics?: boolean,
  59545. /**
  59546. * 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)
  59547. */
  59548. gammaSpace?: boolean,
  59549. /**
  59550. * Internal Use Only
  59551. */
  59552. reserved?: boolean);
  59553. /**
  59554. * Execute the current task
  59555. * @param scene defines the scene where you want your assets to be loaded
  59556. * @param onSuccess is a callback called when the task is successfully executed
  59557. * @param onError is a callback called if an error occurs
  59558. */
  59559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59560. }
  59561. /**
  59562. * Define a task used by AssetsManager to load Equirectangular cube textures
  59563. */
  59564. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59565. /**
  59566. * Defines the name of the task
  59567. */
  59568. name: string;
  59569. /**
  59570. * Defines the location of the file to load
  59571. */
  59572. url: string;
  59573. /**
  59574. * Defines the desired size (the more it increases the longer the generation will be)
  59575. */
  59576. size: number;
  59577. /**
  59578. * Defines if mipmaps should not be generated (default is false)
  59579. */
  59580. noMipmap: boolean;
  59581. /**
  59582. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59583. * but the standard material would require them in Gamma space) (default is true)
  59584. */
  59585. gammaSpace: boolean;
  59586. /**
  59587. * Gets the loaded texture
  59588. */
  59589. texture: EquiRectangularCubeTexture;
  59590. /**
  59591. * Callback called when the task is successful
  59592. */
  59593. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59594. /**
  59595. * Callback called when the task is successful
  59596. */
  59597. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59598. /**
  59599. * Creates a new EquiRectangularCubeTextureAssetTask object
  59600. * @param name defines the name of the task
  59601. * @param url defines the location of the file to load
  59602. * @param size defines the desired size (the more it increases the longer the generation will be)
  59603. * If the size is omitted this implies you are using a preprocessed cubemap.
  59604. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59605. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59606. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59607. * (default is true)
  59608. */
  59609. constructor(
  59610. /**
  59611. * Defines the name of the task
  59612. */
  59613. name: string,
  59614. /**
  59615. * Defines the location of the file to load
  59616. */
  59617. url: string,
  59618. /**
  59619. * Defines the desired size (the more it increases the longer the generation will be)
  59620. */
  59621. size: number,
  59622. /**
  59623. * Defines if mipmaps should not be generated (default is false)
  59624. */
  59625. noMipmap?: boolean,
  59626. /**
  59627. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59628. * but the standard material would require them in Gamma space) (default is true)
  59629. */
  59630. gammaSpace?: boolean);
  59631. /**
  59632. * Execute the current task
  59633. * @param scene defines the scene where you want your assets to be loaded
  59634. * @param onSuccess is a callback called when the task is successfully executed
  59635. * @param onError is a callback called if an error occurs
  59636. */
  59637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59638. }
  59639. /**
  59640. * This class can be used to easily import assets into a scene
  59641. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59642. */
  59643. export class AssetsManager {
  59644. private _scene;
  59645. private _isLoading;
  59646. protected _tasks: AbstractAssetTask[];
  59647. protected _waitingTasksCount: number;
  59648. protected _totalTasksCount: number;
  59649. /**
  59650. * Callback called when all tasks are processed
  59651. */
  59652. onFinish: (tasks: AbstractAssetTask[]) => void;
  59653. /**
  59654. * Callback called when a task is successful
  59655. */
  59656. onTaskSuccess: (task: AbstractAssetTask) => void;
  59657. /**
  59658. * Callback called when a task had an error
  59659. */
  59660. onTaskError: (task: AbstractAssetTask) => void;
  59661. /**
  59662. * Callback called when a task is done (whatever the result is)
  59663. */
  59664. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59665. /**
  59666. * Observable called when all tasks are processed
  59667. */
  59668. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59669. /**
  59670. * Observable called when a task had an error
  59671. */
  59672. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59673. /**
  59674. * Observable called when all tasks were executed
  59675. */
  59676. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59677. /**
  59678. * Observable called when a task is done (whatever the result is)
  59679. */
  59680. onProgressObservable: Observable<IAssetsProgressEvent>;
  59681. /**
  59682. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59683. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59684. */
  59685. useDefaultLoadingScreen: boolean;
  59686. /**
  59687. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59688. * when all assets have been downloaded.
  59689. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59690. */
  59691. autoHideLoadingUI: boolean;
  59692. /**
  59693. * Creates a new AssetsManager
  59694. * @param scene defines the scene to work on
  59695. */
  59696. constructor(scene: Scene);
  59697. /**
  59698. * Add a MeshAssetTask to the list of active tasks
  59699. * @param taskName defines the name of the new task
  59700. * @param meshesNames defines the name of meshes to load
  59701. * @param rootUrl defines the root url to use to locate files
  59702. * @param sceneFilename defines the filename of the scene file
  59703. * @returns a new MeshAssetTask object
  59704. */
  59705. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59706. /**
  59707. * Add a TextFileAssetTask to the list of active tasks
  59708. * @param taskName defines the name of the new task
  59709. * @param url defines the url of the file to load
  59710. * @returns a new TextFileAssetTask object
  59711. */
  59712. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59713. /**
  59714. * Add a BinaryFileAssetTask to the list of active tasks
  59715. * @param taskName defines the name of the new task
  59716. * @param url defines the url of the file to load
  59717. * @returns a new BinaryFileAssetTask object
  59718. */
  59719. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59720. /**
  59721. * Add a ImageAssetTask to the list of active tasks
  59722. * @param taskName defines the name of the new task
  59723. * @param url defines the url of the file to load
  59724. * @returns a new ImageAssetTask object
  59725. */
  59726. addImageTask(taskName: string, url: string): ImageAssetTask;
  59727. /**
  59728. * Add a TextureAssetTask to the list of active tasks
  59729. * @param taskName defines the name of the new task
  59730. * @param url defines the url of the file to load
  59731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59732. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59733. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59734. * @returns a new TextureAssetTask object
  59735. */
  59736. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59737. /**
  59738. * Add a CubeTextureAssetTask to the list of active tasks
  59739. * @param taskName defines the name of the new task
  59740. * @param url defines the url of the file to load
  59741. * @param extensions defines the extension to use to load the cube map (can be null)
  59742. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59743. * @param files defines the list of files to load (can be null)
  59744. * @returns a new CubeTextureAssetTask object
  59745. */
  59746. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59747. /**
  59748. *
  59749. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59750. * @param taskName defines the name of the new task
  59751. * @param url defines the url of the file to load
  59752. * @param size defines the size you want for the cubemap (can be null)
  59753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59754. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59755. * @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)
  59756. * @param reserved Internal use only
  59757. * @returns a new HDRCubeTextureAssetTask object
  59758. */
  59759. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59760. /**
  59761. *
  59762. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59763. * @param taskName defines the name of the new task
  59764. * @param url defines the url of the file to load
  59765. * @param size defines the size you want for the cubemap (can be null)
  59766. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59767. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59768. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59769. * @returns a new EquiRectangularCubeTextureAssetTask object
  59770. */
  59771. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59772. /**
  59773. * Remove a task from the assets manager.
  59774. * @param task the task to remove
  59775. */
  59776. removeTask(task: AbstractAssetTask): void;
  59777. private _decreaseWaitingTasksCount;
  59778. private _runTask;
  59779. /**
  59780. * Reset the AssetsManager and remove all tasks
  59781. * @return the current instance of the AssetsManager
  59782. */
  59783. reset(): AssetsManager;
  59784. /**
  59785. * Start the loading process
  59786. * @return the current instance of the AssetsManager
  59787. */
  59788. load(): AssetsManager;
  59789. /**
  59790. * Start the loading process as an async operation
  59791. * @return a promise returning the list of failed tasks
  59792. */
  59793. loadAsync(): Promise<void>;
  59794. }
  59795. }
  59796. declare module BABYLON {
  59797. /**
  59798. * Wrapper class for promise with external resolve and reject.
  59799. */
  59800. export class Deferred<T> {
  59801. /**
  59802. * The promise associated with this deferred object.
  59803. */
  59804. readonly promise: Promise<T>;
  59805. private _resolve;
  59806. private _reject;
  59807. /**
  59808. * The resolve method of the promise associated with this deferred object.
  59809. */
  59810. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59811. /**
  59812. * The reject method of the promise associated with this deferred object.
  59813. */
  59814. readonly reject: (reason?: any) => void;
  59815. /**
  59816. * Constructor for this deferred object.
  59817. */
  59818. constructor();
  59819. }
  59820. }
  59821. declare module BABYLON {
  59822. /**
  59823. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59824. */
  59825. export class MeshExploder {
  59826. private _centerMesh;
  59827. private _meshes;
  59828. private _meshesOrigins;
  59829. private _toCenterVectors;
  59830. private _scaledDirection;
  59831. private _newPosition;
  59832. private _centerPosition;
  59833. /**
  59834. * Explodes meshes from a center mesh.
  59835. * @param meshes The meshes to explode.
  59836. * @param centerMesh The mesh to be center of explosion.
  59837. */
  59838. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59839. private _setCenterMesh;
  59840. /**
  59841. * Get class name
  59842. * @returns "MeshExploder"
  59843. */
  59844. getClassName(): string;
  59845. /**
  59846. * "Exploded meshes"
  59847. * @returns Array of meshes with the centerMesh at index 0.
  59848. */
  59849. getMeshes(): Array<Mesh>;
  59850. /**
  59851. * Explodes meshes giving a specific direction
  59852. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59853. */
  59854. explode(direction?: number): void;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /**
  59859. * Class used to help managing file picking and drag'n'drop
  59860. */
  59861. export class FilesInput {
  59862. /**
  59863. * List of files ready to be loaded
  59864. */
  59865. static readonly FilesToLoad: {
  59866. [key: string]: File;
  59867. };
  59868. /**
  59869. * Callback called when a file is processed
  59870. */
  59871. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59872. private _engine;
  59873. private _currentScene;
  59874. private _sceneLoadedCallback;
  59875. private _progressCallback;
  59876. private _additionalRenderLoopLogicCallback;
  59877. private _textureLoadingCallback;
  59878. private _startingProcessingFilesCallback;
  59879. private _onReloadCallback;
  59880. private _errorCallback;
  59881. private _elementToMonitor;
  59882. private _sceneFileToLoad;
  59883. private _filesToLoad;
  59884. /**
  59885. * Creates a new FilesInput
  59886. * @param engine defines the rendering engine
  59887. * @param scene defines the hosting scene
  59888. * @param sceneLoadedCallback callback called when scene is loaded
  59889. * @param progressCallback callback called to track progress
  59890. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59891. * @param textureLoadingCallback callback called when a texture is loading
  59892. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59893. * @param onReloadCallback callback called when a reload is requested
  59894. * @param errorCallback callback call if an error occurs
  59895. */
  59896. 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);
  59897. private _dragEnterHandler;
  59898. private _dragOverHandler;
  59899. private _dropHandler;
  59900. /**
  59901. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59902. * @param elementToMonitor defines the DOM element to track
  59903. */
  59904. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59905. /**
  59906. * Release all associated resources
  59907. */
  59908. dispose(): void;
  59909. private renderFunction;
  59910. private drag;
  59911. private drop;
  59912. private _traverseFolder;
  59913. private _processFiles;
  59914. /**
  59915. * Load files from a drop event
  59916. * @param event defines the drop event to use as source
  59917. */
  59918. loadFiles(event: any): void;
  59919. private _processReload;
  59920. /**
  59921. * Reload the current scene from the loaded files
  59922. */
  59923. reload(): void;
  59924. }
  59925. }
  59926. declare module BABYLON {
  59927. /**
  59928. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59930. */
  59931. export class SceneOptimization {
  59932. /**
  59933. * Defines the priority of this optimization (0 by default which means first in the list)
  59934. */
  59935. priority: number;
  59936. /**
  59937. * Gets a string describing the action executed by the current optimization
  59938. * @returns description string
  59939. */
  59940. getDescription(): string;
  59941. /**
  59942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59943. * @param scene defines the current scene where to apply this optimization
  59944. * @param optimizer defines the current optimizer
  59945. * @returns true if everything that can be done was applied
  59946. */
  59947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59948. /**
  59949. * Creates the SceneOptimization object
  59950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59951. * @param desc defines the description associated with the optimization
  59952. */
  59953. constructor(
  59954. /**
  59955. * Defines the priority of this optimization (0 by default which means first in the list)
  59956. */
  59957. priority?: number);
  59958. }
  59959. /**
  59960. * Defines an optimization used to reduce the size of render target textures
  59961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59962. */
  59963. export class TextureOptimization extends SceneOptimization {
  59964. /**
  59965. * Defines the priority of this optimization (0 by default which means first in the list)
  59966. */
  59967. priority: number;
  59968. /**
  59969. * 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
  59970. */
  59971. maximumSize: number;
  59972. /**
  59973. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59974. */
  59975. step: number;
  59976. /**
  59977. * Gets a string describing the action executed by the current optimization
  59978. * @returns description string
  59979. */
  59980. getDescription(): string;
  59981. /**
  59982. * Creates the TextureOptimization object
  59983. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59984. * @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
  59985. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59986. */
  59987. constructor(
  59988. /**
  59989. * Defines the priority of this optimization (0 by default which means first in the list)
  59990. */
  59991. priority?: number,
  59992. /**
  59993. * 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
  59994. */
  59995. maximumSize?: number,
  59996. /**
  59997. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59998. */
  59999. step?: number);
  60000. /**
  60001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60002. * @param scene defines the current scene where to apply this optimization
  60003. * @param optimizer defines the current optimizer
  60004. * @returns true if everything that can be done was applied
  60005. */
  60006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60007. }
  60008. /**
  60009. * Defines an optimization used to increase or decrease the rendering resolution
  60010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60011. */
  60012. export class HardwareScalingOptimization extends SceneOptimization {
  60013. /**
  60014. * Defines the priority of this optimization (0 by default which means first in the list)
  60015. */
  60016. priority: number;
  60017. /**
  60018. * Defines the maximum scale to use (2 by default)
  60019. */
  60020. maximumScale: number;
  60021. /**
  60022. * Defines the step to use between two passes (0.5 by default)
  60023. */
  60024. step: number;
  60025. private _currentScale;
  60026. private _directionOffset;
  60027. /**
  60028. * Gets a string describing the action executed by the current optimization
  60029. * @return description string
  60030. */
  60031. getDescription(): string;
  60032. /**
  60033. * Creates the HardwareScalingOptimization object
  60034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60035. * @param maximumScale defines the maximum scale to use (2 by default)
  60036. * @param step defines the step to use between two passes (0.5 by default)
  60037. */
  60038. constructor(
  60039. /**
  60040. * Defines the priority of this optimization (0 by default which means first in the list)
  60041. */
  60042. priority?: number,
  60043. /**
  60044. * Defines the maximum scale to use (2 by default)
  60045. */
  60046. maximumScale?: number,
  60047. /**
  60048. * Defines the step to use between two passes (0.5 by default)
  60049. */
  60050. step?: number);
  60051. /**
  60052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60053. * @param scene defines the current scene where to apply this optimization
  60054. * @param optimizer defines the current optimizer
  60055. * @returns true if everything that can be done was applied
  60056. */
  60057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60058. }
  60059. /**
  60060. * Defines an optimization used to remove shadows
  60061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60062. */
  60063. export class ShadowsOptimization extends SceneOptimization {
  60064. /**
  60065. * Gets a string describing the action executed by the current optimization
  60066. * @return description string
  60067. */
  60068. getDescription(): string;
  60069. /**
  60070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60071. * @param scene defines the current scene where to apply this optimization
  60072. * @param optimizer defines the current optimizer
  60073. * @returns true if everything that can be done was applied
  60074. */
  60075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60076. }
  60077. /**
  60078. * Defines an optimization used to turn post-processes off
  60079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60080. */
  60081. export class PostProcessesOptimization extends SceneOptimization {
  60082. /**
  60083. * Gets a string describing the action executed by the current optimization
  60084. * @return description string
  60085. */
  60086. getDescription(): string;
  60087. /**
  60088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60089. * @param scene defines the current scene where to apply this optimization
  60090. * @param optimizer defines the current optimizer
  60091. * @returns true if everything that can be done was applied
  60092. */
  60093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60094. }
  60095. /**
  60096. * Defines an optimization used to turn lens flares off
  60097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60098. */
  60099. export class LensFlaresOptimization extends SceneOptimization {
  60100. /**
  60101. * Gets a string describing the action executed by the current optimization
  60102. * @return description string
  60103. */
  60104. getDescription(): string;
  60105. /**
  60106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60107. * @param scene defines the current scene where to apply this optimization
  60108. * @param optimizer defines the current optimizer
  60109. * @returns true if everything that can be done was applied
  60110. */
  60111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60112. }
  60113. /**
  60114. * Defines an optimization based on user defined callback.
  60115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60116. */
  60117. export class CustomOptimization extends SceneOptimization {
  60118. /**
  60119. * Callback called to apply the custom optimization.
  60120. */
  60121. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60122. /**
  60123. * Callback called to get custom description
  60124. */
  60125. onGetDescription: () => string;
  60126. /**
  60127. * Gets a string describing the action executed by the current optimization
  60128. * @returns description string
  60129. */
  60130. getDescription(): string;
  60131. /**
  60132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60133. * @param scene defines the current scene where to apply this optimization
  60134. * @param optimizer defines the current optimizer
  60135. * @returns true if everything that can be done was applied
  60136. */
  60137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60138. }
  60139. /**
  60140. * Defines an optimization used to turn particles off
  60141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60142. */
  60143. export class ParticlesOptimization extends SceneOptimization {
  60144. /**
  60145. * Gets a string describing the action executed by the current optimization
  60146. * @return description string
  60147. */
  60148. getDescription(): string;
  60149. /**
  60150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60151. * @param scene defines the current scene where to apply this optimization
  60152. * @param optimizer defines the current optimizer
  60153. * @returns true if everything that can be done was applied
  60154. */
  60155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60156. }
  60157. /**
  60158. * Defines an optimization used to turn render targets off
  60159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60160. */
  60161. export class RenderTargetsOptimization extends SceneOptimization {
  60162. /**
  60163. * Gets a string describing the action executed by the current optimization
  60164. * @return description string
  60165. */
  60166. getDescription(): string;
  60167. /**
  60168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60169. * @param scene defines the current scene where to apply this optimization
  60170. * @param optimizer defines the current optimizer
  60171. * @returns true if everything that can be done was applied
  60172. */
  60173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60174. }
  60175. /**
  60176. * Defines an optimization used to merge meshes with compatible materials
  60177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60178. */
  60179. export class MergeMeshesOptimization extends SceneOptimization {
  60180. private static _UpdateSelectionTree;
  60181. /**
  60182. * Gets or sets a boolean which defines if optimization octree has to be updated
  60183. */
  60184. /**
  60185. * Gets or sets a boolean which defines if optimization octree has to be updated
  60186. */
  60187. static UpdateSelectionTree: boolean;
  60188. /**
  60189. * Gets a string describing the action executed by the current optimization
  60190. * @return description string
  60191. */
  60192. getDescription(): string;
  60193. private _canBeMerged;
  60194. /**
  60195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60196. * @param scene defines the current scene where to apply this optimization
  60197. * @param optimizer defines the current optimizer
  60198. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60199. * @returns true if everything that can be done was applied
  60200. */
  60201. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60202. }
  60203. /**
  60204. * Defines a list of options used by SceneOptimizer
  60205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60206. */
  60207. export class SceneOptimizerOptions {
  60208. /**
  60209. * Defines the target frame rate to reach (60 by default)
  60210. */
  60211. targetFrameRate: number;
  60212. /**
  60213. * Defines the interval between two checkes (2000ms by default)
  60214. */
  60215. trackerDuration: number;
  60216. /**
  60217. * Gets the list of optimizations to apply
  60218. */
  60219. optimizations: SceneOptimization[];
  60220. /**
  60221. * Creates a new list of options used by SceneOptimizer
  60222. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60223. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60224. */
  60225. constructor(
  60226. /**
  60227. * Defines the target frame rate to reach (60 by default)
  60228. */
  60229. targetFrameRate?: number,
  60230. /**
  60231. * Defines the interval between two checkes (2000ms by default)
  60232. */
  60233. trackerDuration?: number);
  60234. /**
  60235. * Add a new optimization
  60236. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60237. * @returns the current SceneOptimizerOptions
  60238. */
  60239. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60240. /**
  60241. * Add a new custom optimization
  60242. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60243. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60245. * @returns the current SceneOptimizerOptions
  60246. */
  60247. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60248. /**
  60249. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60250. * @param targetFrameRate defines the target frame rate (60 by default)
  60251. * @returns a SceneOptimizerOptions object
  60252. */
  60253. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60254. /**
  60255. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60256. * @param targetFrameRate defines the target frame rate (60 by default)
  60257. * @returns a SceneOptimizerOptions object
  60258. */
  60259. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60260. /**
  60261. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60262. * @param targetFrameRate defines the target frame rate (60 by default)
  60263. * @returns a SceneOptimizerOptions object
  60264. */
  60265. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60266. }
  60267. /**
  60268. * Class used to run optimizations in order to reach a target frame rate
  60269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60270. */
  60271. export class SceneOptimizer implements IDisposable {
  60272. private _isRunning;
  60273. private _options;
  60274. private _scene;
  60275. private _currentPriorityLevel;
  60276. private _targetFrameRate;
  60277. private _trackerDuration;
  60278. private _currentFrameRate;
  60279. private _sceneDisposeObserver;
  60280. private _improvementMode;
  60281. /**
  60282. * Defines an observable called when the optimizer reaches the target frame rate
  60283. */
  60284. onSuccessObservable: Observable<SceneOptimizer>;
  60285. /**
  60286. * Defines an observable called when the optimizer enables an optimization
  60287. */
  60288. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60289. /**
  60290. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60291. */
  60292. onFailureObservable: Observable<SceneOptimizer>;
  60293. /**
  60294. * Gets a boolean indicating if the optimizer is in improvement mode
  60295. */
  60296. readonly isInImprovementMode: boolean;
  60297. /**
  60298. * Gets the current priority level (0 at start)
  60299. */
  60300. readonly currentPriorityLevel: number;
  60301. /**
  60302. * Gets the current frame rate checked by the SceneOptimizer
  60303. */
  60304. readonly currentFrameRate: number;
  60305. /**
  60306. * Gets or sets the current target frame rate (60 by default)
  60307. */
  60308. /**
  60309. * Gets or sets the current target frame rate (60 by default)
  60310. */
  60311. targetFrameRate: number;
  60312. /**
  60313. * Gets or sets the current interval between two checks (every 2000ms by default)
  60314. */
  60315. /**
  60316. * Gets or sets the current interval between two checks (every 2000ms by default)
  60317. */
  60318. trackerDuration: number;
  60319. /**
  60320. * Gets the list of active optimizations
  60321. */
  60322. readonly optimizations: SceneOptimization[];
  60323. /**
  60324. * Creates a new SceneOptimizer
  60325. * @param scene defines the scene to work on
  60326. * @param options defines the options to use with the SceneOptimizer
  60327. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60328. * @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)
  60329. */
  60330. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60331. /**
  60332. * Stops the current optimizer
  60333. */
  60334. stop(): void;
  60335. /**
  60336. * Reset the optimizer to initial step (current priority level = 0)
  60337. */
  60338. reset(): void;
  60339. /**
  60340. * Start the optimizer. By default it will try to reach a specific framerate
  60341. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60342. */
  60343. start(): void;
  60344. private _checkCurrentState;
  60345. /**
  60346. * Release all resources
  60347. */
  60348. dispose(): void;
  60349. /**
  60350. * Helper function to create a SceneOptimizer with one single line of code
  60351. * @param scene defines the scene to work on
  60352. * @param options defines the options to use with the SceneOptimizer
  60353. * @param onSuccess defines a callback to call on success
  60354. * @param onFailure defines a callback to call on failure
  60355. * @returns the new SceneOptimizer object
  60356. */
  60357. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60358. }
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Class used to serialize a scene into a string
  60363. */
  60364. export class SceneSerializer {
  60365. /**
  60366. * Clear cache used by a previous serialization
  60367. */
  60368. static ClearCache(): void;
  60369. /**
  60370. * Serialize a scene into a JSON compatible object
  60371. * @param scene defines the scene to serialize
  60372. * @returns a JSON compatible object
  60373. */
  60374. static Serialize(scene: Scene): any;
  60375. /**
  60376. * Serialize a mesh into a JSON compatible object
  60377. * @param toSerialize defines the mesh to serialize
  60378. * @param withParents defines if parents must be serialized as well
  60379. * @param withChildren defines if children must be serialized as well
  60380. * @returns a JSON compatible object
  60381. */
  60382. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60383. }
  60384. }
  60385. declare module BABYLON {
  60386. /**
  60387. * Class used to host texture specific utilities
  60388. */
  60389. export class TextureTools {
  60390. /**
  60391. * Uses the GPU to create a copy texture rescaled at a given size
  60392. * @param texture Texture to copy from
  60393. * @param width defines the desired width
  60394. * @param height defines the desired height
  60395. * @param useBilinearMode defines if bilinear mode has to be used
  60396. * @return the generated texture
  60397. */
  60398. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60399. }
  60400. }
  60401. declare module BABYLON {
  60402. /**
  60403. * This represents the different options available for the video capture.
  60404. */
  60405. export interface VideoRecorderOptions {
  60406. /** Defines the mime type of the video. */
  60407. mimeType: string;
  60408. /** Defines the FPS the video should be recorded at. */
  60409. fps: number;
  60410. /** Defines the chunk size for the recording data. */
  60411. recordChunckSize: number;
  60412. /** The audio tracks to attach to the recording. */
  60413. audioTracks?: MediaStreamTrack[];
  60414. }
  60415. /**
  60416. * This can help with recording videos from BabylonJS.
  60417. * This is based on the available WebRTC functionalities of the browser.
  60418. *
  60419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60420. */
  60421. export class VideoRecorder {
  60422. private static readonly _defaultOptions;
  60423. /**
  60424. * Returns whether or not the VideoRecorder is available in your browser.
  60425. * @param engine Defines the Babylon Engine.
  60426. * @returns true if supported otherwise false.
  60427. */
  60428. static IsSupported(engine: Engine): boolean;
  60429. private readonly _options;
  60430. private _canvas;
  60431. private _mediaRecorder;
  60432. private _recordedChunks;
  60433. private _fileName;
  60434. private _resolve;
  60435. private _reject;
  60436. /**
  60437. * True when a recording is already in progress.
  60438. */
  60439. readonly isRecording: boolean;
  60440. /**
  60441. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60442. * @param engine Defines the BabylonJS Engine you wish to record.
  60443. * @param options Defines options that can be used to customize the capture.
  60444. */
  60445. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60446. /**
  60447. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60448. */
  60449. stopRecording(): void;
  60450. /**
  60451. * Starts recording the canvas for a max duration specified in parameters.
  60452. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60453. * If null no automatic download will start and you can rely on the promise to get the data back.
  60454. * @param maxDuration Defines the maximum recording time in seconds.
  60455. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60456. * @return A promise callback at the end of the recording with the video data in Blob.
  60457. */
  60458. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60459. /**
  60460. * Releases internal resources used during the recording.
  60461. */
  60462. dispose(): void;
  60463. private _handleDataAvailable;
  60464. private _handleError;
  60465. private _handleStop;
  60466. }
  60467. }
  60468. declare module BABYLON {
  60469. /**
  60470. * Class containing a set of static utilities functions for screenshots
  60471. */
  60472. export class ScreenshotTools {
  60473. /**
  60474. * Captures a screenshot of the current rendering
  60475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60476. * @param engine defines the rendering engine
  60477. * @param camera defines the source camera
  60478. * @param size This parameter can be set to a single number or to an object with the
  60479. * following (optional) properties: precision, width, height. If a single number is passed,
  60480. * it will be used for both width and height. If an object is passed, the screenshot size
  60481. * will be derived from the parameters. The precision property is a multiplier allowing
  60482. * rendering at a higher or lower resolution
  60483. * @param successCallback defines the callback receives a single parameter which contains the
  60484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60485. * src parameter of an <img> to display it
  60486. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60487. * Check your browser for supported MIME types
  60488. */
  60489. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  60490. /**
  60491. * Captures a screenshot of the current rendering
  60492. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60493. * @param engine defines the rendering engine
  60494. * @param camera defines the source camera
  60495. * @param size This parameter can be set to a single number or to an object with the
  60496. * following (optional) properties: precision, width, height. If a single number is passed,
  60497. * it will be used for both width and height. If an object is passed, the screenshot size
  60498. * will be derived from the parameters. The precision property is a multiplier allowing
  60499. * rendering at a higher or lower resolution
  60500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60501. * Check your browser for supported MIME types
  60502. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60503. * to the src parameter of an <img> to display it
  60504. */
  60505. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  60506. /**
  60507. * Generates an image screenshot from the specified camera.
  60508. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60509. * @param engine The engine to use for rendering
  60510. * @param camera The camera to use for rendering
  60511. * @param size This parameter can be set to a single number or to an object with the
  60512. * following (optional) properties: precision, width, height. If a single number is passed,
  60513. * it will be used for both width and height. If an object is passed, the screenshot size
  60514. * will be derived from the parameters. The precision property is a multiplier allowing
  60515. * rendering at a higher or lower resolution
  60516. * @param successCallback The callback receives a single parameter which contains the
  60517. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60518. * src parameter of an <img> to display it
  60519. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60520. * Check your browser for supported MIME types
  60521. * @param samples Texture samples (default: 1)
  60522. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60523. * @param fileName A name for for the downloaded file.
  60524. */
  60525. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60526. /**
  60527. * Generates an image screenshot from the specified camera.
  60528. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60529. * @param engine The engine to use for rendering
  60530. * @param camera The camera to use for rendering
  60531. * @param size This parameter can be set to a single number or to an object with the
  60532. * following (optional) properties: precision, width, height. If a single number is passed,
  60533. * it will be used for both width and height. If an object is passed, the screenshot size
  60534. * will be derived from the parameters. The precision property is a multiplier allowing
  60535. * rendering at a higher or lower resolution
  60536. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60537. * Check your browser for supported MIME types
  60538. * @param samples Texture samples (default: 1)
  60539. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60540. * @param fileName A name for for the downloaded file.
  60541. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60542. * to the src parameter of an <img> to display it
  60543. */
  60544. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  60545. }
  60546. }
  60547. declare module BABYLON {
  60548. /**
  60549. * A cursor which tracks a point on a path
  60550. */
  60551. export class PathCursor {
  60552. private path;
  60553. /**
  60554. * Stores path cursor callbacks for when an onchange event is triggered
  60555. */
  60556. private _onchange;
  60557. /**
  60558. * The value of the path cursor
  60559. */
  60560. value: number;
  60561. /**
  60562. * The animation array of the path cursor
  60563. */
  60564. animations: Animation[];
  60565. /**
  60566. * Initializes the path cursor
  60567. * @param path The path to track
  60568. */
  60569. constructor(path: Path2);
  60570. /**
  60571. * Gets the cursor point on the path
  60572. * @returns A point on the path cursor at the cursor location
  60573. */
  60574. getPoint(): Vector3;
  60575. /**
  60576. * Moves the cursor ahead by the step amount
  60577. * @param step The amount to move the cursor forward
  60578. * @returns This path cursor
  60579. */
  60580. moveAhead(step?: number): PathCursor;
  60581. /**
  60582. * Moves the cursor behind by the step amount
  60583. * @param step The amount to move the cursor back
  60584. * @returns This path cursor
  60585. */
  60586. moveBack(step?: number): PathCursor;
  60587. /**
  60588. * Moves the cursor by the step amount
  60589. * If the step amount is greater than one, an exception is thrown
  60590. * @param step The amount to move the cursor
  60591. * @returns This path cursor
  60592. */
  60593. move(step: number): PathCursor;
  60594. /**
  60595. * Ensures that the value is limited between zero and one
  60596. * @returns This path cursor
  60597. */
  60598. private ensureLimits;
  60599. /**
  60600. * Runs onchange callbacks on change (used by the animation engine)
  60601. * @returns This path cursor
  60602. */
  60603. private raiseOnChange;
  60604. /**
  60605. * Executes a function on change
  60606. * @param f A path cursor onchange callback
  60607. * @returns This path cursor
  60608. */
  60609. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60610. }
  60611. }
  60612. declare module BABYLON {
  60613. /** @hidden */
  60614. export var blurPixelShader: {
  60615. name: string;
  60616. shader: string;
  60617. };
  60618. }
  60619. declare module BABYLON {
  60620. /** @hidden */
  60621. export var pointCloudVertexDeclaration: {
  60622. name: string;
  60623. shader: string;
  60624. };
  60625. }
  60626. // Mixins
  60627. interface Window {
  60628. mozIndexedDB: IDBFactory;
  60629. webkitIndexedDB: IDBFactory;
  60630. msIndexedDB: IDBFactory;
  60631. webkitURL: typeof URL;
  60632. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60633. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60634. WebGLRenderingContext: WebGLRenderingContext;
  60635. MSGesture: MSGesture;
  60636. CANNON: any;
  60637. AudioContext: AudioContext;
  60638. webkitAudioContext: AudioContext;
  60639. PointerEvent: any;
  60640. Math: Math;
  60641. Uint8Array: Uint8ArrayConstructor;
  60642. Float32Array: Float32ArrayConstructor;
  60643. mozURL: typeof URL;
  60644. msURL: typeof URL;
  60645. VRFrameData: any; // WebVR, from specs 1.1
  60646. DracoDecoderModule: any;
  60647. setImmediate(handler: (...args: any[]) => void): number;
  60648. }
  60649. interface HTMLCanvasElement {
  60650. requestPointerLock(): void;
  60651. msRequestPointerLock?(): void;
  60652. mozRequestPointerLock?(): void;
  60653. webkitRequestPointerLock?(): void;
  60654. /** Track wether a record is in progress */
  60655. isRecording: boolean;
  60656. /** Capture Stream method defined by some browsers */
  60657. captureStream(fps?: number): MediaStream;
  60658. }
  60659. interface CanvasRenderingContext2D {
  60660. msImageSmoothingEnabled: boolean;
  60661. }
  60662. interface MouseEvent {
  60663. mozMovementX: number;
  60664. mozMovementY: number;
  60665. webkitMovementX: number;
  60666. webkitMovementY: number;
  60667. msMovementX: number;
  60668. msMovementY: number;
  60669. }
  60670. interface Navigator {
  60671. mozGetVRDevices: (any: any) => any;
  60672. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60673. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60674. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60675. webkitGetGamepads(): Gamepad[];
  60676. msGetGamepads(): Gamepad[];
  60677. webkitGamepads(): Gamepad[];
  60678. }
  60679. interface HTMLVideoElement {
  60680. mozSrcObject: any;
  60681. }
  60682. interface Math {
  60683. fround(x: number): number;
  60684. imul(a: number, b: number): number;
  60685. }
  60686. interface WebGLRenderingContext {
  60687. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60688. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60689. vertexAttribDivisor(index: number, divisor: number): void;
  60690. createVertexArray(): any;
  60691. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60692. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60693. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60694. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60695. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60696. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60697. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60698. // Queries
  60699. createQuery(): WebGLQuery;
  60700. deleteQuery(query: WebGLQuery): void;
  60701. beginQuery(target: number, query: WebGLQuery): void;
  60702. endQuery(target: number): void;
  60703. getQueryParameter(query: WebGLQuery, pname: number): any;
  60704. getQuery(target: number, pname: number): any;
  60705. MAX_SAMPLES: number;
  60706. RGBA8: number;
  60707. READ_FRAMEBUFFER: number;
  60708. DRAW_FRAMEBUFFER: number;
  60709. UNIFORM_BUFFER: number;
  60710. HALF_FLOAT_OES: number;
  60711. RGBA16F: number;
  60712. RGBA32F: number;
  60713. R32F: number;
  60714. RG32F: number;
  60715. RGB32F: number;
  60716. R16F: number;
  60717. RG16F: number;
  60718. RGB16F: number;
  60719. RED: number;
  60720. RG: number;
  60721. R8: number;
  60722. RG8: number;
  60723. UNSIGNED_INT_24_8: number;
  60724. DEPTH24_STENCIL8: number;
  60725. /* Multiple Render Targets */
  60726. drawBuffers(buffers: number[]): void;
  60727. readBuffer(src: number): void;
  60728. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  60729. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  60730. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  60731. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  60732. // Occlusion Query
  60733. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  60734. ANY_SAMPLES_PASSED: number;
  60735. QUERY_RESULT_AVAILABLE: number;
  60736. QUERY_RESULT: number;
  60737. }
  60738. interface WebGLProgram {
  60739. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60740. }
  60741. interface EXT_disjoint_timer_query {
  60742. QUERY_COUNTER_BITS_EXT: number;
  60743. TIME_ELAPSED_EXT: number;
  60744. TIMESTAMP_EXT: number;
  60745. GPU_DISJOINT_EXT: number;
  60746. QUERY_RESULT_EXT: number;
  60747. QUERY_RESULT_AVAILABLE_EXT: number;
  60748. queryCounterEXT(query: WebGLQuery, target: number): void;
  60749. createQueryEXT(): WebGLQuery;
  60750. beginQueryEXT(target: number, query: WebGLQuery): void;
  60751. endQueryEXT(target: number): void;
  60752. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60753. deleteQueryEXT(query: WebGLQuery): void;
  60754. }
  60755. interface WebGLUniformLocation {
  60756. _currentState: any;
  60757. }
  60758. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60759. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60760. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60761. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60762. interface WebGLRenderingContext {
  60763. readonly RASTERIZER_DISCARD: number;
  60764. readonly DEPTH_COMPONENT24: number;
  60765. readonly TEXTURE_3D: number;
  60766. readonly TEXTURE_2D_ARRAY: number;
  60767. readonly TEXTURE_COMPARE_FUNC: number;
  60768. readonly TEXTURE_COMPARE_MODE: number;
  60769. readonly COMPARE_REF_TO_TEXTURE: number;
  60770. readonly TEXTURE_WRAP_R: number;
  60771. readonly HALF_FLOAT: number;
  60772. readonly RGB8: number;
  60773. readonly RED_INTEGER: number;
  60774. readonly RG_INTEGER: number;
  60775. readonly RGB_INTEGER: number;
  60776. readonly RGBA_INTEGER: number;
  60777. readonly R8_SNORM: number;
  60778. readonly RG8_SNORM: number;
  60779. readonly RGB8_SNORM: number;
  60780. readonly RGBA8_SNORM: number;
  60781. readonly R8I: number;
  60782. readonly RG8I: number;
  60783. readonly RGB8I: number;
  60784. readonly RGBA8I: number;
  60785. readonly R8UI: number;
  60786. readonly RG8UI: number;
  60787. readonly RGB8UI: number;
  60788. readonly RGBA8UI: number;
  60789. readonly R16I: number;
  60790. readonly RG16I: number;
  60791. readonly RGB16I: number;
  60792. readonly RGBA16I: number;
  60793. readonly R16UI: number;
  60794. readonly RG16UI: number;
  60795. readonly RGB16UI: number;
  60796. readonly RGBA16UI: number;
  60797. readonly R32I: number;
  60798. readonly RG32I: number;
  60799. readonly RGB32I: number;
  60800. readonly RGBA32I: number;
  60801. readonly R32UI: number;
  60802. readonly RG32UI: number;
  60803. readonly RGB32UI: number;
  60804. readonly RGBA32UI: number;
  60805. readonly RGB10_A2UI: number;
  60806. readonly R11F_G11F_B10F: number;
  60807. readonly RGB9_E5: number;
  60808. readonly RGB10_A2: number;
  60809. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60810. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60811. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60812. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60813. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60814. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60815. 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;
  60816. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60817. readonly TRANSFORM_FEEDBACK: number;
  60818. readonly INTERLEAVED_ATTRIBS: number;
  60819. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60820. createTransformFeedback(): WebGLTransformFeedback;
  60821. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60822. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60823. beginTransformFeedback(primitiveMode: number): void;
  60824. endTransformFeedback(): void;
  60825. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60826. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60827. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60828. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60829. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60830. }
  60831. interface ImageBitmap {
  60832. readonly width: number;
  60833. readonly height: number;
  60834. close(): void;
  60835. }
  60836. interface WebGLQuery extends WebGLObject {
  60837. }
  60838. declare var WebGLQuery: {
  60839. prototype: WebGLQuery;
  60840. new(): WebGLQuery;
  60841. };
  60842. interface WebGLSampler extends WebGLObject {
  60843. }
  60844. declare var WebGLSampler: {
  60845. prototype: WebGLSampler;
  60846. new(): WebGLSampler;
  60847. };
  60848. interface WebGLSync extends WebGLObject {
  60849. }
  60850. declare var WebGLSync: {
  60851. prototype: WebGLSync;
  60852. new(): WebGLSync;
  60853. };
  60854. interface WebGLTransformFeedback extends WebGLObject {
  60855. }
  60856. declare var WebGLTransformFeedback: {
  60857. prototype: WebGLTransformFeedback;
  60858. new(): WebGLTransformFeedback;
  60859. };
  60860. interface WebGLVertexArrayObject extends WebGLObject {
  60861. }
  60862. declare var WebGLVertexArrayObject: {
  60863. prototype: WebGLVertexArrayObject;
  60864. new(): WebGLVertexArrayObject;
  60865. };
  60866. // Type definitions for WebVR API
  60867. // Project: https://w3c.github.io/webvr/
  60868. // Definitions by: six a <https://github.com/lostfictions>
  60869. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60870. interface VRDisplay extends EventTarget {
  60871. /**
  60872. * Dictionary of capabilities describing the VRDisplay.
  60873. */
  60874. readonly capabilities: VRDisplayCapabilities;
  60875. /**
  60876. * z-depth defining the far plane of the eye view frustum
  60877. * enables mapping of values in the render target depth
  60878. * attachment to scene coordinates. Initially set to 10000.0.
  60879. */
  60880. depthFar: number;
  60881. /**
  60882. * z-depth defining the near plane of the eye view frustum
  60883. * enables mapping of values in the render target depth
  60884. * attachment to scene coordinates. Initially set to 0.01.
  60885. */
  60886. depthNear: number;
  60887. /**
  60888. * An identifier for this distinct VRDisplay. Used as an
  60889. * association point in the Gamepad API.
  60890. */
  60891. readonly displayId: number;
  60892. /**
  60893. * A display name, a user-readable name identifying it.
  60894. */
  60895. readonly displayName: string;
  60896. readonly isConnected: boolean;
  60897. readonly isPresenting: boolean;
  60898. /**
  60899. * If this VRDisplay supports room-scale experiences, the optional
  60900. * stage attribute contains details on the room-scale parameters.
  60901. */
  60902. readonly stageParameters: VRStageParameters | null;
  60903. /**
  60904. * Passing the value returned by `requestAnimationFrame` to
  60905. * `cancelAnimationFrame` will unregister the callback.
  60906. * @param handle Define the hanle of the request to cancel
  60907. */
  60908. cancelAnimationFrame(handle: number): void;
  60909. /**
  60910. * Stops presenting to the VRDisplay.
  60911. * @returns a promise to know when it stopped
  60912. */
  60913. exitPresent(): Promise<void>;
  60914. /**
  60915. * Return the current VREyeParameters for the given eye.
  60916. * @param whichEye Define the eye we want the parameter for
  60917. * @returns the eye parameters
  60918. */
  60919. getEyeParameters(whichEye: string): VREyeParameters;
  60920. /**
  60921. * Populates the passed VRFrameData with the information required to render
  60922. * the current frame.
  60923. * @param frameData Define the data structure to populate
  60924. * @returns true if ok otherwise false
  60925. */
  60926. getFrameData(frameData: VRFrameData): boolean;
  60927. /**
  60928. * Get the layers currently being presented.
  60929. * @returns the list of VR layers
  60930. */
  60931. getLayers(): VRLayer[];
  60932. /**
  60933. * Return a VRPose containing the future predicted pose of the VRDisplay
  60934. * when the current frame will be presented. The value returned will not
  60935. * change until JavaScript has returned control to the browser.
  60936. *
  60937. * The VRPose will contain the position, orientation, velocity,
  60938. * and acceleration of each of these properties.
  60939. * @returns the pose object
  60940. */
  60941. getPose(): VRPose;
  60942. /**
  60943. * Return the current instantaneous pose of the VRDisplay, with no
  60944. * prediction applied.
  60945. * @returns the current instantaneous pose
  60946. */
  60947. getImmediatePose(): VRPose;
  60948. /**
  60949. * The callback passed to `requestAnimationFrame` will be called
  60950. * any time a new frame should be rendered. When the VRDisplay is
  60951. * presenting the callback will be called at the native refresh
  60952. * rate of the HMD. When not presenting this function acts
  60953. * identically to how window.requestAnimationFrame acts. Content should
  60954. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60955. * asynchronously from other displays and at differing refresh rates.
  60956. * @param callback Define the eaction to run next frame
  60957. * @returns the request handle it
  60958. */
  60959. requestAnimationFrame(callback: FrameRequestCallback): number;
  60960. /**
  60961. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60962. * Repeat calls while already presenting will update the VRLayers being displayed.
  60963. * @param layers Define the list of layer to present
  60964. * @returns a promise to know when the request has been fulfilled
  60965. */
  60966. requestPresent(layers: VRLayer[]): Promise<void>;
  60967. /**
  60968. * Reset the pose for this display, treating its current position and
  60969. * orientation as the "origin/zero" values. VRPose.position,
  60970. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60971. * updated when calling resetPose(). This should be called in only
  60972. * sitting-space experiences.
  60973. */
  60974. resetPose(): void;
  60975. /**
  60976. * The VRLayer provided to the VRDisplay will be captured and presented
  60977. * in the HMD. Calling this function has the same effect on the source
  60978. * canvas as any other operation that uses its source image, and canvases
  60979. * created without preserveDrawingBuffer set to true will be cleared.
  60980. * @param pose Define the pose to submit
  60981. */
  60982. submitFrame(pose?: VRPose): void;
  60983. }
  60984. declare var VRDisplay: {
  60985. prototype: VRDisplay;
  60986. new(): VRDisplay;
  60987. };
  60988. interface VRLayer {
  60989. leftBounds?: number[] | Float32Array | null;
  60990. rightBounds?: number[] | Float32Array | null;
  60991. source?: HTMLCanvasElement | null;
  60992. }
  60993. interface VRDisplayCapabilities {
  60994. readonly canPresent: boolean;
  60995. readonly hasExternalDisplay: boolean;
  60996. readonly hasOrientation: boolean;
  60997. readonly hasPosition: boolean;
  60998. readonly maxLayers: number;
  60999. }
  61000. interface VREyeParameters {
  61001. /** @deprecated */
  61002. readonly fieldOfView: VRFieldOfView;
  61003. readonly offset: Float32Array;
  61004. readonly renderHeight: number;
  61005. readonly renderWidth: number;
  61006. }
  61007. interface VRFieldOfView {
  61008. readonly downDegrees: number;
  61009. readonly leftDegrees: number;
  61010. readonly rightDegrees: number;
  61011. readonly upDegrees: number;
  61012. }
  61013. interface VRFrameData {
  61014. readonly leftProjectionMatrix: Float32Array;
  61015. readonly leftViewMatrix: Float32Array;
  61016. readonly pose: VRPose;
  61017. readonly rightProjectionMatrix: Float32Array;
  61018. readonly rightViewMatrix: Float32Array;
  61019. readonly timestamp: number;
  61020. }
  61021. interface VRPose {
  61022. readonly angularAcceleration: Float32Array | null;
  61023. readonly angularVelocity: Float32Array | null;
  61024. readonly linearAcceleration: Float32Array | null;
  61025. readonly linearVelocity: Float32Array | null;
  61026. readonly orientation: Float32Array | null;
  61027. readonly position: Float32Array | null;
  61028. readonly timestamp: number;
  61029. }
  61030. interface VRStageParameters {
  61031. sittingToStandingTransform?: Float32Array;
  61032. sizeX?: number;
  61033. sizeY?: number;
  61034. }
  61035. interface Navigator {
  61036. getVRDisplays(): Promise<VRDisplay[]>;
  61037. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61038. }
  61039. interface Window {
  61040. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61041. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61042. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61043. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61044. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61045. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61046. }
  61047. interface Gamepad {
  61048. readonly displayId: number;
  61049. }
  61050. type XRSessionMode =
  61051. | "inline"
  61052. | "immersive-vr"
  61053. | "immersive-ar";
  61054. type XRReferenceSpaceType =
  61055. | "viewer"
  61056. | "local"
  61057. | "local-floor"
  61058. | "bounded-floor"
  61059. | "unbounded";
  61060. type XREnvironmentBlendMode =
  61061. | "opaque"
  61062. | "additive"
  61063. | "alpha-blend";
  61064. type XRVisibilityState =
  61065. | "visible"
  61066. | "visible-blurred"
  61067. | "hidden";
  61068. type XRHandedness =
  61069. | "none"
  61070. | "left"
  61071. | "right";
  61072. type XRTargetRayMode =
  61073. | "gaze"
  61074. | "tracked-pointer"
  61075. | "screen";
  61076. type XREye =
  61077. | "none"
  61078. | "left"
  61079. | "right";
  61080. interface XRSpace extends EventTarget {
  61081. }
  61082. interface XRRenderState {
  61083. depthNear?: number;
  61084. depthFar?: number;
  61085. inlineVerticalFieldOfView?: number;
  61086. baseLayer?: XRWebGLLayer;
  61087. }
  61088. interface XRInputSource {
  61089. handedness: XRHandedness;
  61090. targetRayMode: XRTargetRayMode;
  61091. targetRaySpace: XRSpace;
  61092. gripSpace: XRSpace | undefined;
  61093. gamepad: Gamepad | undefined;
  61094. profiles: Array<string>;
  61095. }
  61096. interface XRSession {
  61097. addEventListener: Function;
  61098. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61099. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61100. requestAnimationFrame: Function;
  61101. end(): Promise<void>;
  61102. renderState: XRRenderState;
  61103. inputSources: Array<XRInputSource>;
  61104. }
  61105. interface XRReferenceSpace extends XRSpace {
  61106. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61107. onreset: any;
  61108. }
  61109. interface XRFrame {
  61110. session: XRSession;
  61111. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61112. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61113. }
  61114. interface XRViewerPose extends XRPose {
  61115. views: Array<XRView>;
  61116. }
  61117. interface XRPose {
  61118. transform: XRRigidTransform;
  61119. emulatedPosition: boolean;
  61120. }
  61121. declare var XRWebGLLayer: {
  61122. prototype: XRWebGLLayer;
  61123. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61124. };
  61125. interface XRWebGLLayer {
  61126. framebuffer: WebGLFramebuffer;
  61127. framebufferWidth: number;
  61128. framebufferHeight: number;
  61129. getViewport: Function;
  61130. }
  61131. interface XRRigidTransform {
  61132. position: DOMPointReadOnly;
  61133. orientation: DOMPointReadOnly;
  61134. matrix: Float32Array;
  61135. inverse: XRRigidTransform;
  61136. }
  61137. interface XRView {
  61138. eye: XREye;
  61139. projectionMatrix: Float32Array;
  61140. transform: XRRigidTransform;
  61141. }
  61142. interface XRInputSourceChangeEvent {
  61143. session: XRSession;
  61144. removed: Array<XRInputSource>;
  61145. added: Array<XRInputSource>;
  61146. }
  61147. declare module BABYLON.GUI {
  61148. /**
  61149. * Class used to specific a value and its associated unit
  61150. */
  61151. export class ValueAndUnit {
  61152. /** defines the unit to store */
  61153. unit: number;
  61154. /** defines a boolean indicating if the value can be negative */
  61155. negativeValueAllowed: boolean;
  61156. private _value;
  61157. private _originalUnit;
  61158. /**
  61159. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61160. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61161. */
  61162. ignoreAdaptiveScaling: boolean;
  61163. /**
  61164. * Creates a new ValueAndUnit
  61165. * @param value defines the value to store
  61166. * @param unit defines the unit to store
  61167. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61168. */
  61169. constructor(value: number,
  61170. /** defines the unit to store */
  61171. unit?: number,
  61172. /** defines a boolean indicating if the value can be negative */
  61173. negativeValueAllowed?: boolean);
  61174. /** Gets a boolean indicating if the value is a percentage */
  61175. readonly isPercentage: boolean;
  61176. /** Gets a boolean indicating if the value is store as pixel */
  61177. readonly isPixel: boolean;
  61178. /** Gets direct internal value */
  61179. readonly internalValue: number;
  61180. /**
  61181. * Gets value as pixel
  61182. * @param host defines the root host
  61183. * @param refValue defines the reference value for percentages
  61184. * @returns the value as pixel
  61185. */
  61186. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61187. /**
  61188. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61189. * @param value defines the value to store
  61190. * @param unit defines the unit to store
  61191. * @returns the current ValueAndUnit
  61192. */
  61193. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61194. /**
  61195. * Gets the value accordingly to its unit
  61196. * @param host defines the root host
  61197. * @returns the value
  61198. */
  61199. getValue(host: AdvancedDynamicTexture): number;
  61200. /**
  61201. * Gets a string representation of the value
  61202. * @param host defines the root host
  61203. * @param decimals defines an optional number of decimals to display
  61204. * @returns a string
  61205. */
  61206. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61207. /**
  61208. * Store a value parsed from a string
  61209. * @param source defines the source string
  61210. * @returns true if the value was successfully parsed
  61211. */
  61212. fromString(source: string | number): boolean;
  61213. private static _Regex;
  61214. private static _UNITMODE_PERCENTAGE;
  61215. private static _UNITMODE_PIXEL;
  61216. /** UNITMODE_PERCENTAGE */
  61217. static readonly UNITMODE_PERCENTAGE: number;
  61218. /** UNITMODE_PIXEL */
  61219. static readonly UNITMODE_PIXEL: number;
  61220. }
  61221. }
  61222. declare module BABYLON.GUI {
  61223. /**
  61224. * Define a style used by control to automatically setup properties based on a template.
  61225. * Only support font related properties so far
  61226. */
  61227. export class Style implements BABYLON.IDisposable {
  61228. private _fontFamily;
  61229. private _fontStyle;
  61230. private _fontWeight;
  61231. /** @hidden */
  61232. _host: AdvancedDynamicTexture;
  61233. /** @hidden */
  61234. _fontSize: ValueAndUnit;
  61235. /**
  61236. * BABYLON.Observable raised when the style values are changed
  61237. */
  61238. onChangedObservable: BABYLON.Observable<Style>;
  61239. /**
  61240. * Creates a new style object
  61241. * @param host defines the AdvancedDynamicTexture which hosts this style
  61242. */
  61243. constructor(host: AdvancedDynamicTexture);
  61244. /**
  61245. * Gets or sets the font size
  61246. */
  61247. fontSize: string | number;
  61248. /**
  61249. * Gets or sets the font family
  61250. */
  61251. fontFamily: string;
  61252. /**
  61253. * Gets or sets the font style
  61254. */
  61255. fontStyle: string;
  61256. /** Gets or sets font weight */
  61257. fontWeight: string;
  61258. /** Dispose all associated resources */
  61259. dispose(): void;
  61260. }
  61261. }
  61262. declare module BABYLON.GUI {
  61263. /**
  61264. * Class used to transport BABYLON.Vector2 information for pointer events
  61265. */
  61266. export class Vector2WithInfo extends BABYLON.Vector2 {
  61267. /** defines the current mouse button index */
  61268. buttonIndex: number;
  61269. /**
  61270. * Creates a new Vector2WithInfo
  61271. * @param source defines the vector2 data to transport
  61272. * @param buttonIndex defines the current mouse button index
  61273. */
  61274. constructor(source: BABYLON.Vector2,
  61275. /** defines the current mouse button index */
  61276. buttonIndex?: number);
  61277. }
  61278. /** Class used to provide 2D matrix features */
  61279. export class Matrix2D {
  61280. /** Gets the internal array of 6 floats used to store matrix data */
  61281. m: Float32Array;
  61282. /**
  61283. * Creates a new matrix
  61284. * @param m00 defines value for (0, 0)
  61285. * @param m01 defines value for (0, 1)
  61286. * @param m10 defines value for (1, 0)
  61287. * @param m11 defines value for (1, 1)
  61288. * @param m20 defines value for (2, 0)
  61289. * @param m21 defines value for (2, 1)
  61290. */
  61291. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61292. /**
  61293. * Fills the matrix from direct values
  61294. * @param m00 defines value for (0, 0)
  61295. * @param m01 defines value for (0, 1)
  61296. * @param m10 defines value for (1, 0)
  61297. * @param m11 defines value for (1, 1)
  61298. * @param m20 defines value for (2, 0)
  61299. * @param m21 defines value for (2, 1)
  61300. * @returns the current modified matrix
  61301. */
  61302. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61303. /**
  61304. * Gets matrix determinant
  61305. * @returns the determinant
  61306. */
  61307. determinant(): number;
  61308. /**
  61309. * Inverses the matrix and stores it in a target matrix
  61310. * @param result defines the target matrix
  61311. * @returns the current matrix
  61312. */
  61313. invertToRef(result: Matrix2D): Matrix2D;
  61314. /**
  61315. * Multiplies the current matrix with another one
  61316. * @param other defines the second operand
  61317. * @param result defines the target matrix
  61318. * @returns the current matrix
  61319. */
  61320. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61321. /**
  61322. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61323. * @param x defines the x coordinate to transform
  61324. * @param y defines the x coordinate to transform
  61325. * @param result defines the target vector2
  61326. * @returns the current matrix
  61327. */
  61328. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61329. /**
  61330. * Creates an identity matrix
  61331. * @returns a new matrix
  61332. */
  61333. static Identity(): Matrix2D;
  61334. /**
  61335. * Creates a translation matrix and stores it in a target matrix
  61336. * @param x defines the x coordinate of the translation
  61337. * @param y defines the y coordinate of the translation
  61338. * @param result defines the target matrix
  61339. */
  61340. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61341. /**
  61342. * Creates a scaling matrix and stores it in a target matrix
  61343. * @param x defines the x coordinate of the scaling
  61344. * @param y defines the y coordinate of the scaling
  61345. * @param result defines the target matrix
  61346. */
  61347. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61348. /**
  61349. * Creates a rotation matrix and stores it in a target matrix
  61350. * @param angle defines the rotation angle
  61351. * @param result defines the target matrix
  61352. */
  61353. static RotationToRef(angle: number, result: Matrix2D): void;
  61354. private static _TempPreTranslationMatrix;
  61355. private static _TempPostTranslationMatrix;
  61356. private static _TempRotationMatrix;
  61357. private static _TempScalingMatrix;
  61358. private static _TempCompose0;
  61359. private static _TempCompose1;
  61360. private static _TempCompose2;
  61361. /**
  61362. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61363. * @param tx defines the x coordinate of the translation
  61364. * @param ty defines the y coordinate of the translation
  61365. * @param angle defines the rotation angle
  61366. * @param scaleX defines the x coordinate of the scaling
  61367. * @param scaleY defines the y coordinate of the scaling
  61368. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61369. * @param result defines the target matrix
  61370. */
  61371. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61372. }
  61373. }
  61374. declare module BABYLON.GUI {
  61375. /**
  61376. * Class used to store 2D control sizes
  61377. */
  61378. export class Measure {
  61379. /** defines left coordinate */
  61380. left: number;
  61381. /** defines top coordinate */
  61382. top: number;
  61383. /** defines width dimension */
  61384. width: number;
  61385. /** defines height dimension */
  61386. height: number;
  61387. /**
  61388. * Creates a new measure
  61389. * @param left defines left coordinate
  61390. * @param top defines top coordinate
  61391. * @param width defines width dimension
  61392. * @param height defines height dimension
  61393. */
  61394. constructor(
  61395. /** defines left coordinate */
  61396. left: number,
  61397. /** defines top coordinate */
  61398. top: number,
  61399. /** defines width dimension */
  61400. width: number,
  61401. /** defines height dimension */
  61402. height: number);
  61403. /**
  61404. * Copy from another measure
  61405. * @param other defines the other measure to copy from
  61406. */
  61407. copyFrom(other: Measure): void;
  61408. /**
  61409. * Copy from a group of 4 floats
  61410. * @param left defines left coordinate
  61411. * @param top defines top coordinate
  61412. * @param width defines width dimension
  61413. * @param height defines height dimension
  61414. */
  61415. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61416. /**
  61417. * Computes the axis aligned bounding box measure for two given measures
  61418. * @param a Input measure
  61419. * @param b Input measure
  61420. * @param result the resulting bounding measure
  61421. */
  61422. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61423. /**
  61424. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61425. * @param transform the matrix to transform the measure before computing the AABB
  61426. * @param result the resulting AABB
  61427. */
  61428. transformToRef(transform: Matrix2D, result: Measure): void;
  61429. /**
  61430. * Check equality between this measure and another one
  61431. * @param other defines the other measures
  61432. * @returns true if both measures are equals
  61433. */
  61434. isEqualsTo(other: Measure): boolean;
  61435. /**
  61436. * Creates an empty measure
  61437. * @returns a new measure
  61438. */
  61439. static Empty(): Measure;
  61440. }
  61441. }
  61442. declare module BABYLON.GUI {
  61443. /**
  61444. * Interface used to define a control that can receive focus
  61445. */
  61446. export interface IFocusableControl {
  61447. /**
  61448. * Function called when the control receives the focus
  61449. */
  61450. onFocus(): void;
  61451. /**
  61452. * Function called when the control loses the focus
  61453. */
  61454. onBlur(): void;
  61455. /**
  61456. * Function called to let the control handle keyboard events
  61457. * @param evt defines the current keyboard event
  61458. */
  61459. processKeyboard(evt: KeyboardEvent): void;
  61460. /**
  61461. * Function called to get the list of controls that should not steal the focus from this control
  61462. * @returns an array of controls
  61463. */
  61464. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61465. }
  61466. /**
  61467. * Class used to create texture to support 2D GUI elements
  61468. * @see http://doc.babylonjs.com/how_to/gui
  61469. */
  61470. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61471. private _isDirty;
  61472. private _renderObserver;
  61473. private _resizeObserver;
  61474. private _preKeyboardObserver;
  61475. private _pointerMoveObserver;
  61476. private _pointerObserver;
  61477. private _canvasPointerOutObserver;
  61478. private _background;
  61479. /** @hidden */
  61480. _rootContainer: Container;
  61481. /** @hidden */
  61482. _lastPickedControl: Control;
  61483. /** @hidden */
  61484. _lastControlOver: {
  61485. [pointerId: number]: Control;
  61486. };
  61487. /** @hidden */
  61488. _lastControlDown: {
  61489. [pointerId: number]: Control;
  61490. };
  61491. /** @hidden */
  61492. _capturingControl: {
  61493. [pointerId: number]: Control;
  61494. };
  61495. /** @hidden */
  61496. _shouldBlockPointer: boolean;
  61497. /** @hidden */
  61498. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61499. /** @hidden */
  61500. _linkedControls: Control[];
  61501. private _isFullscreen;
  61502. private _fullscreenViewport;
  61503. private _idealWidth;
  61504. private _idealHeight;
  61505. private _useSmallestIdeal;
  61506. private _renderAtIdealSize;
  61507. private _focusedControl;
  61508. private _blockNextFocusCheck;
  61509. private _renderScale;
  61510. private _rootCanvas;
  61511. private _cursorChanged;
  61512. /**
  61513. * Define type to string to ensure compatibility across browsers
  61514. * Safari doesn't support DataTransfer constructor
  61515. */
  61516. private _clipboardData;
  61517. /**
  61518. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61519. */
  61520. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61521. /**
  61522. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61523. */
  61524. onControlPickedObservable: BABYLON.Observable<Control>;
  61525. /**
  61526. * BABYLON.Observable event triggered before layout is evaluated
  61527. */
  61528. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61529. /**
  61530. * BABYLON.Observable event triggered after the layout was evaluated
  61531. */
  61532. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61533. /**
  61534. * BABYLON.Observable event triggered before the texture is rendered
  61535. */
  61536. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61537. /**
  61538. * BABYLON.Observable event triggered after the texture was rendered
  61539. */
  61540. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61541. /**
  61542. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61543. */
  61544. premulAlpha: boolean;
  61545. /**
  61546. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61547. * Useful when you want more antialiasing
  61548. */
  61549. renderScale: number;
  61550. /** Gets or sets the background color */
  61551. background: string;
  61552. /**
  61553. * Gets or sets the ideal width used to design controls.
  61554. * The GUI will then rescale everything accordingly
  61555. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61556. */
  61557. idealWidth: number;
  61558. /**
  61559. * Gets or sets the ideal height used to design controls.
  61560. * The GUI will then rescale everything accordingly
  61561. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61562. */
  61563. idealHeight: number;
  61564. /**
  61565. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61566. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61567. */
  61568. useSmallestIdeal: boolean;
  61569. /**
  61570. * Gets or sets a boolean indicating if adaptive scaling must be used
  61571. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61572. */
  61573. renderAtIdealSize: boolean;
  61574. /**
  61575. * Gets the underlying layer used to render the texture when in fullscreen mode
  61576. */
  61577. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61578. /**
  61579. * Gets the root container control
  61580. */
  61581. readonly rootContainer: Container;
  61582. /**
  61583. * Returns an array containing the root container.
  61584. * This is mostly used to let the Inspector introspects the ADT
  61585. * @returns an array containing the rootContainer
  61586. */
  61587. getChildren(): Array<Container>;
  61588. /**
  61589. * Will return all controls that are inside this texture
  61590. * @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
  61591. * @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
  61592. * @return all child controls
  61593. */
  61594. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61595. /**
  61596. * Gets or sets the current focused control
  61597. */
  61598. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61599. /**
  61600. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61601. */
  61602. isForeground: boolean;
  61603. /**
  61604. * Gets or set information about clipboardData
  61605. */
  61606. clipboardData: string;
  61607. /**
  61608. * Creates a new AdvancedDynamicTexture
  61609. * @param name defines the name of the texture
  61610. * @param width defines the width of the texture
  61611. * @param height defines the height of the texture
  61612. * @param scene defines the hosting scene
  61613. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61614. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61615. */
  61616. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61617. /**
  61618. * Get the current class name of the texture useful for serialization or dynamic coding.
  61619. * @returns "AdvancedDynamicTexture"
  61620. */
  61621. getClassName(): string;
  61622. /**
  61623. * Function used to execute a function on all controls
  61624. * @param func defines the function to execute
  61625. * @param container defines the container where controls belong. If null the root container will be used
  61626. */
  61627. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61628. private _useInvalidateRectOptimization;
  61629. /**
  61630. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61631. */
  61632. useInvalidateRectOptimization: boolean;
  61633. private _invalidatedRectangle;
  61634. /**
  61635. * Invalidates a rectangle area on the gui texture
  61636. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61637. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61638. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61639. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61640. */
  61641. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61642. /**
  61643. * Marks the texture as dirty forcing a complete update
  61644. */
  61645. markAsDirty(): void;
  61646. /**
  61647. * Helper function used to create a new style
  61648. * @returns a new style
  61649. * @see http://doc.babylonjs.com/how_to/gui#styles
  61650. */
  61651. createStyle(): Style;
  61652. /**
  61653. * Adds a new control to the root container
  61654. * @param control defines the control to add
  61655. * @returns the current texture
  61656. */
  61657. addControl(control: Control): AdvancedDynamicTexture;
  61658. /**
  61659. * Removes a control from the root container
  61660. * @param control defines the control to remove
  61661. * @returns the current texture
  61662. */
  61663. removeControl(control: Control): AdvancedDynamicTexture;
  61664. /**
  61665. * Release all resources
  61666. */
  61667. dispose(): void;
  61668. private _onResize;
  61669. /** @hidden */
  61670. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61671. /**
  61672. * Get screen coordinates for a vector3
  61673. * @param position defines the position to project
  61674. * @param worldMatrix defines the world matrix to use
  61675. * @returns the projected position
  61676. */
  61677. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61678. private _checkUpdate;
  61679. private _clearMeasure;
  61680. private _render;
  61681. /** @hidden */
  61682. _changeCursor(cursor: string): void;
  61683. /** @hidden */
  61684. _registerLastControlDown(control: Control, pointerId: number): void;
  61685. private _doPicking;
  61686. /** @hidden */
  61687. _cleanControlAfterRemovalFromList(list: {
  61688. [pointerId: number]: Control;
  61689. }, control: Control): void;
  61690. /** @hidden */
  61691. _cleanControlAfterRemoval(control: Control): void;
  61692. /** Attach to all scene events required to support pointer events */
  61693. attach(): void;
  61694. /** @hidden */
  61695. private onClipboardCopy;
  61696. /** @hidden */
  61697. private onClipboardCut;
  61698. /** @hidden */
  61699. private onClipboardPaste;
  61700. /**
  61701. * Register the clipboard Events onto the canvas
  61702. */
  61703. registerClipboardEvents(): void;
  61704. /**
  61705. * Unregister the clipboard Events from the canvas
  61706. */
  61707. unRegisterClipboardEvents(): void;
  61708. /**
  61709. * Connect the texture to a hosting mesh to enable interactions
  61710. * @param mesh defines the mesh to attach to
  61711. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  61712. */
  61713. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  61714. /**
  61715. * Move the focus to a specific control
  61716. * @param control defines the control which will receive the focus
  61717. */
  61718. moveFocusToControl(control: IFocusableControl): void;
  61719. private _manageFocus;
  61720. private _attachToOnPointerOut;
  61721. /**
  61722. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  61723. * @param mesh defines the mesh which will receive the texture
  61724. * @param width defines the texture width (1024 by default)
  61725. * @param height defines the texture height (1024 by default)
  61726. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  61727. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  61728. * @returns a new AdvancedDynamicTexture
  61729. */
  61730. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  61731. /**
  61732. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  61733. * In this mode the texture will rely on a layer for its rendering.
  61734. * This allows it to be treated like any other layer.
  61735. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  61736. * LayerMask is set through advancedTexture.layer.layerMask
  61737. * @param name defines name for the texture
  61738. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61739. * @param scene defines the hsoting scene
  61740. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61741. * @returns a new AdvancedDynamicTexture
  61742. */
  61743. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61744. }
  61745. }
  61746. declare module BABYLON.GUI {
  61747. /**
  61748. * Root class used for all 2D controls
  61749. * @see http://doc.babylonjs.com/how_to/gui#controls
  61750. */
  61751. export class Control {
  61752. /** defines the name of the control */
  61753. name?: string | undefined;
  61754. /**
  61755. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61756. */
  61757. static AllowAlphaInheritance: boolean;
  61758. private _alpha;
  61759. private _alphaSet;
  61760. private _zIndex;
  61761. /** @hidden */
  61762. _host: AdvancedDynamicTexture;
  61763. /** Gets or sets the control parent */
  61764. parent: BABYLON.Nullable<Container>;
  61765. /** @hidden */
  61766. _currentMeasure: Measure;
  61767. private _fontFamily;
  61768. private _fontStyle;
  61769. private _fontWeight;
  61770. private _fontSize;
  61771. private _font;
  61772. /** @hidden */
  61773. _width: ValueAndUnit;
  61774. /** @hidden */
  61775. _height: ValueAndUnit;
  61776. /** @hidden */
  61777. protected _fontOffset: {
  61778. ascent: number;
  61779. height: number;
  61780. descent: number;
  61781. };
  61782. private _color;
  61783. private _style;
  61784. private _styleObserver;
  61785. /** @hidden */
  61786. protected _horizontalAlignment: number;
  61787. /** @hidden */
  61788. protected _verticalAlignment: number;
  61789. /** @hidden */
  61790. protected _isDirty: boolean;
  61791. /** @hidden */
  61792. protected _wasDirty: boolean;
  61793. /** @hidden */
  61794. _tempParentMeasure: Measure;
  61795. /** @hidden */
  61796. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61797. /** @hidden */
  61798. protected _cachedParentMeasure: Measure;
  61799. private _paddingLeft;
  61800. private _paddingRight;
  61801. private _paddingTop;
  61802. private _paddingBottom;
  61803. /** @hidden */
  61804. _left: ValueAndUnit;
  61805. /** @hidden */
  61806. _top: ValueAndUnit;
  61807. private _scaleX;
  61808. private _scaleY;
  61809. private _rotation;
  61810. private _transformCenterX;
  61811. private _transformCenterY;
  61812. /** @hidden */
  61813. _transformMatrix: Matrix2D;
  61814. /** @hidden */
  61815. protected _invertTransformMatrix: Matrix2D;
  61816. /** @hidden */
  61817. protected _transformedPosition: BABYLON.Vector2;
  61818. private _isMatrixDirty;
  61819. private _cachedOffsetX;
  61820. private _cachedOffsetY;
  61821. private _isVisible;
  61822. private _isHighlighted;
  61823. /** @hidden */
  61824. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61825. private _fontSet;
  61826. private _dummyVector2;
  61827. private _downCount;
  61828. private _enterCount;
  61829. private _doNotRender;
  61830. private _downPointerIds;
  61831. protected _isEnabled: boolean;
  61832. protected _disabledColor: string;
  61833. /** @hidden */
  61834. protected _rebuildLayout: boolean;
  61835. /** @hidden */
  61836. _isClipped: boolean;
  61837. /** @hidden */
  61838. _tag: any;
  61839. /**
  61840. * 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
  61841. */
  61842. uniqueId: number;
  61843. /**
  61844. * Gets or sets an object used to store user defined information for the node
  61845. */
  61846. metadata: any;
  61847. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61848. isHitTestVisible: boolean;
  61849. /** Gets or sets a boolean indicating if the control can block pointer events */
  61850. isPointerBlocker: boolean;
  61851. /** Gets or sets a boolean indicating if the control can be focusable */
  61852. isFocusInvisible: boolean;
  61853. /**
  61854. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61855. * 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
  61856. */
  61857. clipChildren: boolean;
  61858. /**
  61859. * Gets or sets a boolean indicating that control content must be clipped
  61860. * 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
  61861. */
  61862. clipContent: boolean;
  61863. /**
  61864. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61865. */
  61866. useBitmapCache: boolean;
  61867. private _cacheData;
  61868. private _shadowOffsetX;
  61869. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61870. shadowOffsetX: number;
  61871. private _shadowOffsetY;
  61872. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61873. shadowOffsetY: number;
  61874. private _shadowBlur;
  61875. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61876. shadowBlur: number;
  61877. private _shadowColor;
  61878. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61879. shadowColor: string;
  61880. /** Gets or sets the cursor to use when the control is hovered */
  61881. hoverCursor: string;
  61882. /** @hidden */
  61883. protected _linkOffsetX: ValueAndUnit;
  61884. /** @hidden */
  61885. protected _linkOffsetY: ValueAndUnit;
  61886. /** Gets the control type name */
  61887. readonly typeName: string;
  61888. /**
  61889. * Get the current class name of the control.
  61890. * @returns current class name
  61891. */
  61892. getClassName(): string;
  61893. /**
  61894. * An event triggered when the pointer move over the control.
  61895. */
  61896. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61897. /**
  61898. * An event triggered when the pointer move out of the control.
  61899. */
  61900. onPointerOutObservable: BABYLON.Observable<Control>;
  61901. /**
  61902. * An event triggered when the pointer taps the control
  61903. */
  61904. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61905. /**
  61906. * An event triggered when pointer up
  61907. */
  61908. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61909. /**
  61910. * An event triggered when a control is clicked on
  61911. */
  61912. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61913. /**
  61914. * An event triggered when pointer enters the control
  61915. */
  61916. onPointerEnterObservable: BABYLON.Observable<Control>;
  61917. /**
  61918. * An event triggered when the control is marked as dirty
  61919. */
  61920. onDirtyObservable: BABYLON.Observable<Control>;
  61921. /**
  61922. * An event triggered before drawing the control
  61923. */
  61924. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61925. /**
  61926. * An event triggered after the control was drawn
  61927. */
  61928. onAfterDrawObservable: BABYLON.Observable<Control>;
  61929. /**
  61930. * Get the hosting AdvancedDynamicTexture
  61931. */
  61932. readonly host: AdvancedDynamicTexture;
  61933. /** Gets or set information about font offsets (used to render and align text) */
  61934. fontOffset: {
  61935. ascent: number;
  61936. height: number;
  61937. descent: number;
  61938. };
  61939. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61940. alpha: number;
  61941. /**
  61942. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61943. */
  61944. isHighlighted: boolean;
  61945. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61946. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61947. */
  61948. scaleX: number;
  61949. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61950. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61951. */
  61952. scaleY: number;
  61953. /** Gets or sets the rotation angle (0 by default)
  61954. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61955. */
  61956. rotation: number;
  61957. /** Gets or sets the transformation center on Y axis (0 by default)
  61958. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61959. */
  61960. transformCenterY: number;
  61961. /** Gets or sets the transformation center on X axis (0 by default)
  61962. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61963. */
  61964. transformCenterX: number;
  61965. /**
  61966. * Gets or sets the horizontal alignment
  61967. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61968. */
  61969. horizontalAlignment: number;
  61970. /**
  61971. * Gets or sets the vertical alignment
  61972. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61973. */
  61974. verticalAlignment: number;
  61975. /**
  61976. * Gets or sets control width
  61977. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61978. */
  61979. width: string | number;
  61980. /**
  61981. * Gets or sets the control width in pixel
  61982. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61983. */
  61984. widthInPixels: number;
  61985. /**
  61986. * Gets or sets control height
  61987. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61988. */
  61989. height: string | number;
  61990. /**
  61991. * Gets or sets control height in pixel
  61992. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61993. */
  61994. heightInPixels: number;
  61995. /** Gets or set font family */
  61996. fontFamily: string;
  61997. /** Gets or sets font style */
  61998. fontStyle: string;
  61999. /** Gets or sets font weight */
  62000. fontWeight: string;
  62001. /**
  62002. * Gets or sets style
  62003. * @see http://doc.babylonjs.com/how_to/gui#styles
  62004. */
  62005. style: BABYLON.Nullable<Style>;
  62006. /** @hidden */
  62007. readonly _isFontSizeInPercentage: boolean;
  62008. /** Gets or sets font size in pixels */
  62009. fontSizeInPixels: number;
  62010. /** Gets or sets font size */
  62011. fontSize: string | number;
  62012. /** Gets or sets foreground color */
  62013. color: string;
  62014. /** Gets or sets z index which is used to reorder controls on the z axis */
  62015. zIndex: number;
  62016. /** Gets or sets a boolean indicating if the control can be rendered */
  62017. notRenderable: boolean;
  62018. /** Gets or sets a boolean indicating if the control is visible */
  62019. isVisible: boolean;
  62020. /** Gets a boolean indicating that the control needs to update its rendering */
  62021. readonly isDirty: boolean;
  62022. /**
  62023. * Gets the current linked mesh (or null if none)
  62024. */
  62025. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62026. /**
  62027. * Gets or sets a value indicating the padding to use on the left of the control
  62028. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62029. */
  62030. paddingLeft: string | number;
  62031. /**
  62032. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62033. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62034. */
  62035. paddingLeftInPixels: number;
  62036. /**
  62037. * Gets or sets a value indicating the padding to use on the right of the control
  62038. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62039. */
  62040. paddingRight: string | number;
  62041. /**
  62042. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62043. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62044. */
  62045. paddingRightInPixels: number;
  62046. /**
  62047. * Gets or sets a value indicating the padding to use on the top of the control
  62048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62049. */
  62050. paddingTop: string | number;
  62051. /**
  62052. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62054. */
  62055. paddingTopInPixels: number;
  62056. /**
  62057. * Gets or sets a value indicating the padding to use on the bottom of the control
  62058. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62059. */
  62060. paddingBottom: string | number;
  62061. /**
  62062. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62063. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62064. */
  62065. paddingBottomInPixels: number;
  62066. /**
  62067. * Gets or sets a value indicating the left coordinate of the control
  62068. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62069. */
  62070. left: string | number;
  62071. /**
  62072. * Gets or sets a value indicating the left coordinate in pixels of the control
  62073. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62074. */
  62075. leftInPixels: number;
  62076. /**
  62077. * Gets or sets a value indicating the top coordinate of the control
  62078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62079. */
  62080. top: string | number;
  62081. /**
  62082. * Gets or sets a value indicating the top coordinate in pixels of the control
  62083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62084. */
  62085. topInPixels: number;
  62086. /**
  62087. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62088. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62089. */
  62090. linkOffsetX: string | number;
  62091. /**
  62092. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62093. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62094. */
  62095. linkOffsetXInPixels: number;
  62096. /**
  62097. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62098. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62099. */
  62100. linkOffsetY: string | number;
  62101. /**
  62102. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62103. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62104. */
  62105. linkOffsetYInPixels: number;
  62106. /** Gets the center coordinate on X axis */
  62107. readonly centerX: number;
  62108. /** Gets the center coordinate on Y axis */
  62109. readonly centerY: number;
  62110. /** Gets or sets if control is Enabled*/
  62111. isEnabled: boolean;
  62112. /** Gets or sets background color of control if it's disabled*/
  62113. disabledColor: string;
  62114. /**
  62115. * Creates a new control
  62116. * @param name defines the name of the control
  62117. */
  62118. constructor(
  62119. /** defines the name of the control */
  62120. name?: string | undefined);
  62121. /** @hidden */
  62122. protected _getTypeName(): string;
  62123. /**
  62124. * Gets the first ascendant in the hierarchy of the given type
  62125. * @param className defines the required type
  62126. * @returns the ascendant or null if not found
  62127. */
  62128. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62129. /** @hidden */
  62130. _resetFontCache(): void;
  62131. /**
  62132. * Determines if a container is an ascendant of the current control
  62133. * @param container defines the container to look for
  62134. * @returns true if the container is one of the ascendant of the control
  62135. */
  62136. isAscendant(container: Control): boolean;
  62137. /**
  62138. * Gets coordinates in local control space
  62139. * @param globalCoordinates defines the coordinates to transform
  62140. * @returns the new coordinates in local space
  62141. */
  62142. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62143. /**
  62144. * Gets coordinates in local control space
  62145. * @param globalCoordinates defines the coordinates to transform
  62146. * @param result defines the target vector2 where to store the result
  62147. * @returns the current control
  62148. */
  62149. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62150. /**
  62151. * Gets coordinates in parent local control space
  62152. * @param globalCoordinates defines the coordinates to transform
  62153. * @returns the new coordinates in parent local space
  62154. */
  62155. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62156. /**
  62157. * Move the current control to a vector3 position projected onto the screen.
  62158. * @param position defines the target position
  62159. * @param scene defines the hosting scene
  62160. */
  62161. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62162. /** @hidden */
  62163. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62164. /**
  62165. * Will return all controls that have this control as ascendant
  62166. * @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
  62167. * @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
  62168. * @return all child controls
  62169. */
  62170. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62171. /**
  62172. * Link current control with a target mesh
  62173. * @param mesh defines the mesh to link with
  62174. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62175. */
  62176. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62177. /** @hidden */
  62178. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62179. /** @hidden */
  62180. _offsetLeft(offset: number): void;
  62181. /** @hidden */
  62182. _offsetTop(offset: number): void;
  62183. /** @hidden */
  62184. _markMatrixAsDirty(): void;
  62185. /** @hidden */
  62186. _flagDescendantsAsMatrixDirty(): void;
  62187. /** @hidden */
  62188. _intersectsRect(rect: Measure): boolean;
  62189. /** @hidden */
  62190. protected invalidateRect(): void;
  62191. /** @hidden */
  62192. _markAsDirty(force?: boolean): void;
  62193. /** @hidden */
  62194. _markAllAsDirty(): void;
  62195. /** @hidden */
  62196. _link(host: AdvancedDynamicTexture): void;
  62197. /** @hidden */
  62198. protected _transform(context?: CanvasRenderingContext2D): void;
  62199. /** @hidden */
  62200. _renderHighlight(context: CanvasRenderingContext2D): void;
  62201. /** @hidden */
  62202. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62203. /** @hidden */
  62204. protected _applyStates(context: CanvasRenderingContext2D): void;
  62205. /** @hidden */
  62206. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62207. /** @hidden */
  62208. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62209. protected _evaluateClippingState(parentMeasure: Measure): void;
  62210. /** @hidden */
  62211. _measure(): void;
  62212. /** @hidden */
  62213. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62214. /** @hidden */
  62215. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62216. /** @hidden */
  62217. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62218. /** @hidden */
  62219. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62220. private static _ClipMeasure;
  62221. private _tmpMeasureA;
  62222. private _clip;
  62223. /** @hidden */
  62224. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62225. /** @hidden */
  62226. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62227. /**
  62228. * Tests if a given coordinates belong to the current control
  62229. * @param x defines x coordinate to test
  62230. * @param y defines y coordinate to test
  62231. * @returns true if the coordinates are inside the control
  62232. */
  62233. contains(x: number, y: number): boolean;
  62234. /** @hidden */
  62235. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62236. /** @hidden */
  62237. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62238. /** @hidden */
  62239. _onPointerEnter(target: Control): boolean;
  62240. /** @hidden */
  62241. _onPointerOut(target: Control, force?: boolean): void;
  62242. /** @hidden */
  62243. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62244. /** @hidden */
  62245. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62246. /** @hidden */
  62247. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62248. /** @hidden */
  62249. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62250. private _prepareFont;
  62251. /** Releases associated resources */
  62252. dispose(): void;
  62253. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62254. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62255. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62256. private static _VERTICAL_ALIGNMENT_TOP;
  62257. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62258. private static _VERTICAL_ALIGNMENT_CENTER;
  62259. /** HORIZONTAL_ALIGNMENT_LEFT */
  62260. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62261. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62262. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62263. /** HORIZONTAL_ALIGNMENT_CENTER */
  62264. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62265. /** VERTICAL_ALIGNMENT_TOP */
  62266. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62267. /** VERTICAL_ALIGNMENT_BOTTOM */
  62268. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62269. /** VERTICAL_ALIGNMENT_CENTER */
  62270. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62271. private static _FontHeightSizes;
  62272. /** @hidden */
  62273. static _GetFontOffset(font: string): {
  62274. ascent: number;
  62275. height: number;
  62276. descent: number;
  62277. };
  62278. /**
  62279. * Creates a stack panel that can be used to render headers
  62280. * @param control defines the control to associate with the header
  62281. * @param text defines the text of the header
  62282. * @param size defines the size of the header
  62283. * @param options defines options used to configure the header
  62284. * @returns a new StackPanel
  62285. * @ignore
  62286. * @hidden
  62287. */
  62288. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62289. isHorizontal: boolean;
  62290. controlFirst: boolean;
  62291. }) => any;
  62292. /** @hidden */
  62293. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62294. }
  62295. }
  62296. declare module BABYLON.GUI {
  62297. /**
  62298. * Root class for 2D containers
  62299. * @see http://doc.babylonjs.com/how_to/gui#containers
  62300. */
  62301. export class Container extends Control {
  62302. name?: string | undefined;
  62303. /** @hidden */
  62304. protected _children: Control[];
  62305. /** @hidden */
  62306. protected _measureForChildren: Measure;
  62307. /** @hidden */
  62308. protected _background: string;
  62309. /** @hidden */
  62310. protected _adaptWidthToChildren: boolean;
  62311. /** @hidden */
  62312. protected _adaptHeightToChildren: boolean;
  62313. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62314. adaptHeightToChildren: boolean;
  62315. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62316. adaptWidthToChildren: boolean;
  62317. /** Gets or sets background color */
  62318. background: string;
  62319. /** Gets the list of children */
  62320. readonly children: Control[];
  62321. /**
  62322. * Creates a new Container
  62323. * @param name defines the name of the container
  62324. */
  62325. constructor(name?: string | undefined);
  62326. protected _getTypeName(): string;
  62327. _flagDescendantsAsMatrixDirty(): void;
  62328. /**
  62329. * Gets a child using its name
  62330. * @param name defines the child name to look for
  62331. * @returns the child control if found
  62332. */
  62333. getChildByName(name: string): BABYLON.Nullable<Control>;
  62334. /**
  62335. * Gets a child using its type and its name
  62336. * @param name defines the child name to look for
  62337. * @param type defines the child type to look for
  62338. * @returns the child control if found
  62339. */
  62340. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62341. /**
  62342. * Search for a specific control in children
  62343. * @param control defines the control to look for
  62344. * @returns true if the control is in child list
  62345. */
  62346. containsControl(control: Control): boolean;
  62347. /**
  62348. * Adds a new control to the current container
  62349. * @param control defines the control to add
  62350. * @returns the current container
  62351. */
  62352. addControl(control: BABYLON.Nullable<Control>): Container;
  62353. /**
  62354. * Removes all controls from the current container
  62355. * @returns the current container
  62356. */
  62357. clearControls(): Container;
  62358. /**
  62359. * Removes a control from the current container
  62360. * @param control defines the control to remove
  62361. * @returns the current container
  62362. */
  62363. removeControl(control: Control): Container;
  62364. /** @hidden */
  62365. _reOrderControl(control: Control): void;
  62366. /** @hidden */
  62367. _offsetLeft(offset: number): void;
  62368. /** @hidden */
  62369. _offsetTop(offset: number): void;
  62370. /** @hidden */
  62371. _markAllAsDirty(): void;
  62372. /** @hidden */
  62373. protected _localDraw(context: CanvasRenderingContext2D): void;
  62374. /** @hidden */
  62375. _link(host: AdvancedDynamicTexture): void;
  62376. /** @hidden */
  62377. protected _beforeLayout(): void;
  62378. /** @hidden */
  62379. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62380. /** @hidden */
  62381. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62382. protected _postMeasure(): void;
  62383. /** @hidden */
  62384. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62385. /** @hidden */
  62386. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62387. /** @hidden */
  62388. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62389. /** @hidden */
  62390. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62391. /** Releases associated resources */
  62392. dispose(): void;
  62393. }
  62394. }
  62395. declare module BABYLON.GUI {
  62396. /** Class used to create rectangle container */
  62397. export class Rectangle extends Container {
  62398. name?: string | undefined;
  62399. private _thickness;
  62400. private _cornerRadius;
  62401. /** Gets or sets border thickness */
  62402. thickness: number;
  62403. /** Gets or sets the corner radius angle */
  62404. cornerRadius: number;
  62405. /**
  62406. * Creates a new Rectangle
  62407. * @param name defines the control name
  62408. */
  62409. constructor(name?: string | undefined);
  62410. protected _getTypeName(): string;
  62411. protected _localDraw(context: CanvasRenderingContext2D): void;
  62412. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62413. private _drawRoundedRect;
  62414. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62415. }
  62416. }
  62417. declare module BABYLON.GUI {
  62418. /**
  62419. * Enum that determines the text-wrapping mode to use.
  62420. */
  62421. export enum TextWrapping {
  62422. /**
  62423. * Clip the text when it's larger than Control.width; this is the default mode.
  62424. */
  62425. Clip = 0,
  62426. /**
  62427. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62428. */
  62429. WordWrap = 1,
  62430. /**
  62431. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62432. */
  62433. Ellipsis = 2
  62434. }
  62435. /**
  62436. * Class used to create text block control
  62437. */
  62438. export class TextBlock extends Control {
  62439. /**
  62440. * Defines the name of the control
  62441. */
  62442. name?: string | undefined;
  62443. private _text;
  62444. private _textWrapping;
  62445. private _textHorizontalAlignment;
  62446. private _textVerticalAlignment;
  62447. private _lines;
  62448. private _resizeToFit;
  62449. private _lineSpacing;
  62450. private _outlineWidth;
  62451. private _outlineColor;
  62452. /**
  62453. * An event triggered after the text is changed
  62454. */
  62455. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62456. /**
  62457. * An event triggered after the text was broken up into lines
  62458. */
  62459. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62460. /**
  62461. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62462. */
  62463. readonly lines: any[];
  62464. /**
  62465. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62466. */
  62467. /**
  62468. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62469. */
  62470. resizeToFit: boolean;
  62471. /**
  62472. * Gets or sets a boolean indicating if text must be wrapped
  62473. */
  62474. /**
  62475. * Gets or sets a boolean indicating if text must be wrapped
  62476. */
  62477. textWrapping: TextWrapping | boolean;
  62478. /**
  62479. * Gets or sets text to display
  62480. */
  62481. /**
  62482. * Gets or sets text to display
  62483. */
  62484. text: string;
  62485. /**
  62486. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62487. */
  62488. /**
  62489. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62490. */
  62491. textHorizontalAlignment: number;
  62492. /**
  62493. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62494. */
  62495. /**
  62496. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62497. */
  62498. textVerticalAlignment: number;
  62499. /**
  62500. * Gets or sets line spacing value
  62501. */
  62502. /**
  62503. * Gets or sets line spacing value
  62504. */
  62505. lineSpacing: string | number;
  62506. /**
  62507. * Gets or sets outlineWidth of the text to display
  62508. */
  62509. /**
  62510. * Gets or sets outlineWidth of the text to display
  62511. */
  62512. outlineWidth: number;
  62513. /**
  62514. * Gets or sets outlineColor of the text to display
  62515. */
  62516. /**
  62517. * Gets or sets outlineColor of the text to display
  62518. */
  62519. outlineColor: string;
  62520. /**
  62521. * Creates a new TextBlock object
  62522. * @param name defines the name of the control
  62523. * @param text defines the text to display (emptry string by default)
  62524. */
  62525. constructor(
  62526. /**
  62527. * Defines the name of the control
  62528. */
  62529. name?: string | undefined, text?: string);
  62530. protected _getTypeName(): string;
  62531. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62532. private _drawText;
  62533. /** @hidden */
  62534. _draw(context: CanvasRenderingContext2D): void;
  62535. protected _applyStates(context: CanvasRenderingContext2D): void;
  62536. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62537. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62538. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62539. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62540. protected _renderLines(context: CanvasRenderingContext2D): void;
  62541. /**
  62542. * Given a width constraint applied on the text block, find the expected height
  62543. * @returns expected height
  62544. */
  62545. computeExpectedHeight(): number;
  62546. dispose(): void;
  62547. }
  62548. }
  62549. declare module BABYLON.GUI {
  62550. /**
  62551. * Class used to create 2D images
  62552. */
  62553. export class Image extends Control {
  62554. name?: string | undefined;
  62555. private static _WorkingCanvas;
  62556. private _domImage;
  62557. private _imageWidth;
  62558. private _imageHeight;
  62559. private _loaded;
  62560. private _stretch;
  62561. private _source;
  62562. private _autoScale;
  62563. private _sourceLeft;
  62564. private _sourceTop;
  62565. private _sourceWidth;
  62566. private _sourceHeight;
  62567. private _cellWidth;
  62568. private _cellHeight;
  62569. private _cellId;
  62570. private _populateNinePatchSlicesFromImage;
  62571. private _sliceLeft;
  62572. private _sliceRight;
  62573. private _sliceTop;
  62574. private _sliceBottom;
  62575. private _detectPointerOnOpaqueOnly;
  62576. /**
  62577. * BABYLON.Observable notified when the content is loaded
  62578. */
  62579. onImageLoadedObservable: BABYLON.Observable<Image>;
  62580. /**
  62581. * Gets a boolean indicating that the content is loaded
  62582. */
  62583. readonly isLoaded: boolean;
  62584. /**
  62585. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62586. */
  62587. populateNinePatchSlicesFromImage: boolean;
  62588. /**
  62589. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62590. * Beware using this as this will comsume more memory as the image has to be stored twice
  62591. */
  62592. detectPointerOnOpaqueOnly: boolean;
  62593. /**
  62594. * Gets or sets the left value for slicing (9-patch)
  62595. */
  62596. sliceLeft: number;
  62597. /**
  62598. * Gets or sets the right value for slicing (9-patch)
  62599. */
  62600. sliceRight: number;
  62601. /**
  62602. * Gets or sets the top value for slicing (9-patch)
  62603. */
  62604. sliceTop: number;
  62605. /**
  62606. * Gets or sets the bottom value for slicing (9-patch)
  62607. */
  62608. sliceBottom: number;
  62609. /**
  62610. * Gets or sets the left coordinate in the source image
  62611. */
  62612. sourceLeft: number;
  62613. /**
  62614. * Gets or sets the top coordinate in the source image
  62615. */
  62616. sourceTop: number;
  62617. /**
  62618. * Gets or sets the width to capture in the source image
  62619. */
  62620. sourceWidth: number;
  62621. /**
  62622. * Gets or sets the height to capture in the source image
  62623. */
  62624. sourceHeight: number;
  62625. /**
  62626. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62627. * @see http://doc.babylonjs.com/how_to/gui#image
  62628. */
  62629. autoScale: boolean;
  62630. /** Gets or sets the streching mode used by the image */
  62631. stretch: number;
  62632. /**
  62633. * Gets or sets the internal DOM image used to render the control
  62634. */
  62635. domImage: HTMLImageElement;
  62636. private _onImageLoaded;
  62637. private _extractNinePatchSliceDataFromImage;
  62638. /**
  62639. * Gets or sets image source url
  62640. */
  62641. source: BABYLON.Nullable<string>;
  62642. /**
  62643. * Gets or sets the cell width to use when animation sheet is enabled
  62644. * @see http://doc.babylonjs.com/how_to/gui#image
  62645. */
  62646. cellWidth: number;
  62647. /**
  62648. * Gets or sets the cell height to use when animation sheet is enabled
  62649. * @see http://doc.babylonjs.com/how_to/gui#image
  62650. */
  62651. cellHeight: number;
  62652. /**
  62653. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62654. * @see http://doc.babylonjs.com/how_to/gui#image
  62655. */
  62656. cellId: number;
  62657. /**
  62658. * Creates a new Image
  62659. * @param name defines the control name
  62660. * @param url defines the image url
  62661. */
  62662. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62663. /**
  62664. * Tests if a given coordinates belong to the current control
  62665. * @param x defines x coordinate to test
  62666. * @param y defines y coordinate to test
  62667. * @returns true if the coordinates are inside the control
  62668. */
  62669. contains(x: number, y: number): boolean;
  62670. protected _getTypeName(): string;
  62671. /** Force the control to synchronize with its content */
  62672. synchronizeSizeWithContent(): void;
  62673. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62674. private _prepareWorkingCanvasForOpaqueDetection;
  62675. private _drawImage;
  62676. _draw(context: CanvasRenderingContext2D): void;
  62677. private _renderCornerPatch;
  62678. private _renderNinePatch;
  62679. dispose(): void;
  62680. /** STRETCH_NONE */
  62681. static readonly STRETCH_NONE: number;
  62682. /** STRETCH_FILL */
  62683. static readonly STRETCH_FILL: number;
  62684. /** STRETCH_UNIFORM */
  62685. static readonly STRETCH_UNIFORM: number;
  62686. /** STRETCH_EXTEND */
  62687. static readonly STRETCH_EXTEND: number;
  62688. /** NINE_PATCH */
  62689. static readonly STRETCH_NINE_PATCH: number;
  62690. }
  62691. }
  62692. declare module BABYLON.GUI {
  62693. /**
  62694. * Class used to create 2D buttons
  62695. */
  62696. export class Button extends Rectangle {
  62697. name?: string | undefined;
  62698. /**
  62699. * Function called to generate a pointer enter animation
  62700. */
  62701. pointerEnterAnimation: () => void;
  62702. /**
  62703. * Function called to generate a pointer out animation
  62704. */
  62705. pointerOutAnimation: () => void;
  62706. /**
  62707. * Function called to generate a pointer down animation
  62708. */
  62709. pointerDownAnimation: () => void;
  62710. /**
  62711. * Function called to generate a pointer up animation
  62712. */
  62713. pointerUpAnimation: () => void;
  62714. /**
  62715. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  62716. */
  62717. delegatePickingToChildren: boolean;
  62718. private _image;
  62719. /**
  62720. * Returns the image part of the button (if any)
  62721. */
  62722. readonly image: BABYLON.Nullable<Image>;
  62723. private _textBlock;
  62724. /**
  62725. * Returns the image part of the button (if any)
  62726. */
  62727. readonly textBlock: BABYLON.Nullable<TextBlock>;
  62728. /**
  62729. * Creates a new Button
  62730. * @param name defines the name of the button
  62731. */
  62732. constructor(name?: string | undefined);
  62733. protected _getTypeName(): string;
  62734. /** @hidden */
  62735. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62736. /** @hidden */
  62737. _onPointerEnter(target: Control): boolean;
  62738. /** @hidden */
  62739. _onPointerOut(target: Control, force?: boolean): void;
  62740. /** @hidden */
  62741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62742. /** @hidden */
  62743. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62744. /**
  62745. * Creates a new button made with an image and a text
  62746. * @param name defines the name of the button
  62747. * @param text defines the text of the button
  62748. * @param imageUrl defines the url of the image
  62749. * @returns a new Button
  62750. */
  62751. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62752. /**
  62753. * Creates a new button made with an image
  62754. * @param name defines the name of the button
  62755. * @param imageUrl defines the url of the image
  62756. * @returns a new Button
  62757. */
  62758. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62759. /**
  62760. * Creates a new button made with a text
  62761. * @param name defines the name of the button
  62762. * @param text defines the text of the button
  62763. * @returns a new Button
  62764. */
  62765. static CreateSimpleButton(name: string, text: string): Button;
  62766. /**
  62767. * Creates a new button made with an image and a centered text
  62768. * @param name defines the name of the button
  62769. * @param text defines the text of the button
  62770. * @param imageUrl defines the url of the image
  62771. * @returns a new Button
  62772. */
  62773. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62774. }
  62775. }
  62776. declare module BABYLON.GUI {
  62777. /**
  62778. * Class used to create a 2D stack panel container
  62779. */
  62780. export class StackPanel extends Container {
  62781. name?: string | undefined;
  62782. private _isVertical;
  62783. private _manualWidth;
  62784. private _manualHeight;
  62785. private _doNotTrackManualChanges;
  62786. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62787. isVertical: boolean;
  62788. /**
  62789. * Gets or sets panel width.
  62790. * This value should not be set when in horizontal mode as it will be computed automatically
  62791. */
  62792. width: string | number;
  62793. /**
  62794. * Gets or sets panel height.
  62795. * This value should not be set when in vertical mode as it will be computed automatically
  62796. */
  62797. height: string | number;
  62798. /**
  62799. * Creates a new StackPanel
  62800. * @param name defines control name
  62801. */
  62802. constructor(name?: string | undefined);
  62803. protected _getTypeName(): string;
  62804. /** @hidden */
  62805. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62806. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62807. protected _postMeasure(): void;
  62808. }
  62809. }
  62810. declare module BABYLON.GUI {
  62811. /**
  62812. * Class used to represent a 2D checkbox
  62813. */
  62814. export class Checkbox extends Control {
  62815. name?: string | undefined;
  62816. private _isChecked;
  62817. private _background;
  62818. private _checkSizeRatio;
  62819. private _thickness;
  62820. /** Gets or sets border thickness */
  62821. thickness: number;
  62822. /**
  62823. * BABYLON.Observable raised when isChecked property changes
  62824. */
  62825. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62826. /** Gets or sets a value indicating the ratio between overall size and check size */
  62827. checkSizeRatio: number;
  62828. /** Gets or sets background color */
  62829. background: string;
  62830. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62831. isChecked: boolean;
  62832. /**
  62833. * Creates a new CheckBox
  62834. * @param name defines the control name
  62835. */
  62836. constructor(name?: string | undefined);
  62837. protected _getTypeName(): string;
  62838. /** @hidden */
  62839. _draw(context: CanvasRenderingContext2D): void;
  62840. /** @hidden */
  62841. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62842. /**
  62843. * Utility function to easily create a checkbox with a header
  62844. * @param title defines the label to use for the header
  62845. * @param onValueChanged defines the callback to call when value changes
  62846. * @returns a StackPanel containing the checkbox and a textBlock
  62847. */
  62848. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62849. }
  62850. }
  62851. declare module BABYLON.GUI {
  62852. /**
  62853. * Class used to store key control properties
  62854. */
  62855. export class KeyPropertySet {
  62856. /** Width */
  62857. width?: string;
  62858. /** Height */
  62859. height?: string;
  62860. /** Left padding */
  62861. paddingLeft?: string;
  62862. /** Right padding */
  62863. paddingRight?: string;
  62864. /** Top padding */
  62865. paddingTop?: string;
  62866. /** Bottom padding */
  62867. paddingBottom?: string;
  62868. /** Foreground color */
  62869. color?: string;
  62870. /** Background color */
  62871. background?: string;
  62872. }
  62873. /**
  62874. * Class used to create virtual keyboard
  62875. */
  62876. export class VirtualKeyboard extends StackPanel {
  62877. /** BABYLON.Observable raised when a key is pressed */
  62878. onKeyPressObservable: BABYLON.Observable<string>;
  62879. /** Gets or sets default key button width */
  62880. defaultButtonWidth: string;
  62881. /** Gets or sets default key button height */
  62882. defaultButtonHeight: string;
  62883. /** Gets or sets default key button left padding */
  62884. defaultButtonPaddingLeft: string;
  62885. /** Gets or sets default key button right padding */
  62886. defaultButtonPaddingRight: string;
  62887. /** Gets or sets default key button top padding */
  62888. defaultButtonPaddingTop: string;
  62889. /** Gets or sets default key button bottom padding */
  62890. defaultButtonPaddingBottom: string;
  62891. /** Gets or sets default key button foreground color */
  62892. defaultButtonColor: string;
  62893. /** Gets or sets default key button background color */
  62894. defaultButtonBackground: string;
  62895. /** Gets or sets shift button foreground color */
  62896. shiftButtonColor: string;
  62897. /** Gets or sets shift button thickness*/
  62898. selectedShiftThickness: number;
  62899. /** Gets shift key state */
  62900. shiftState: number;
  62901. protected _getTypeName(): string;
  62902. private _createKey;
  62903. /**
  62904. * Adds a new row of keys
  62905. * @param keys defines the list of keys to add
  62906. * @param propertySets defines the associated property sets
  62907. */
  62908. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62909. /**
  62910. * Set the shift key to a specific state
  62911. * @param shiftState defines the new shift state
  62912. */
  62913. applyShiftState(shiftState: number): void;
  62914. private _currentlyConnectedInputText;
  62915. private _connectedInputTexts;
  62916. private _onKeyPressObserver;
  62917. /** Gets the input text control currently attached to the keyboard */
  62918. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62919. /**
  62920. * Connects the keyboard with an input text control
  62921. *
  62922. * @param input defines the target control
  62923. */
  62924. connect(input: InputText): void;
  62925. /**
  62926. * Disconnects the keyboard from connected InputText controls
  62927. *
  62928. * @param input optionally defines a target control, otherwise all are disconnected
  62929. */
  62930. disconnect(input?: InputText): void;
  62931. private _removeConnectedInputObservables;
  62932. /**
  62933. * Release all resources
  62934. */
  62935. dispose(): void;
  62936. /**
  62937. * Creates a new keyboard using a default layout
  62938. *
  62939. * @param name defines control name
  62940. * @returns a new VirtualKeyboard
  62941. */
  62942. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62943. }
  62944. }
  62945. declare module BABYLON.GUI {
  62946. /**
  62947. * Class used to create input text control
  62948. */
  62949. export class InputText extends Control implements IFocusableControl {
  62950. name?: string | undefined;
  62951. private _text;
  62952. private _placeholderText;
  62953. private _background;
  62954. private _focusedBackground;
  62955. private _focusedColor;
  62956. private _placeholderColor;
  62957. private _thickness;
  62958. private _margin;
  62959. private _autoStretchWidth;
  62960. private _maxWidth;
  62961. private _isFocused;
  62962. private _blinkTimeout;
  62963. private _blinkIsEven;
  62964. private _cursorOffset;
  62965. private _scrollLeft;
  62966. private _textWidth;
  62967. private _clickedCoordinate;
  62968. private _deadKey;
  62969. private _addKey;
  62970. private _currentKey;
  62971. private _isTextHighlightOn;
  62972. private _textHighlightColor;
  62973. private _highligherOpacity;
  62974. private _highlightedText;
  62975. private _startHighlightIndex;
  62976. private _endHighlightIndex;
  62977. private _cursorIndex;
  62978. private _onFocusSelectAll;
  62979. private _isPointerDown;
  62980. private _onClipboardObserver;
  62981. private _onPointerDblTapObserver;
  62982. /** @hidden */
  62983. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62984. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62985. promptMessage: string;
  62986. /** Force disable prompt on mobile device */
  62987. disableMobilePrompt: boolean;
  62988. /** BABYLON.Observable raised when the text changes */
  62989. onTextChangedObservable: BABYLON.Observable<InputText>;
  62990. /** BABYLON.Observable raised just before an entered character is to be added */
  62991. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62992. /** BABYLON.Observable raised when the control gets the focus */
  62993. onFocusObservable: BABYLON.Observable<InputText>;
  62994. /** BABYLON.Observable raised when the control loses the focus */
  62995. onBlurObservable: BABYLON.Observable<InputText>;
  62996. /**Observable raised when the text is highlighted */
  62997. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62998. /**Observable raised when copy event is triggered */
  62999. onTextCopyObservable: BABYLON.Observable<InputText>;
  63000. /** BABYLON.Observable raised when cut event is triggered */
  63001. onTextCutObservable: BABYLON.Observable<InputText>;
  63002. /** BABYLON.Observable raised when paste event is triggered */
  63003. onTextPasteObservable: BABYLON.Observable<InputText>;
  63004. /** BABYLON.Observable raised when a key event was processed */
  63005. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63006. /** Gets or sets the maximum width allowed by the control */
  63007. maxWidth: string | number;
  63008. /** Gets the maximum width allowed by the control in pixels */
  63009. readonly maxWidthInPixels: number;
  63010. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63011. highligherOpacity: number;
  63012. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63013. onFocusSelectAll: boolean;
  63014. /** Gets or sets the text hightlight color */
  63015. textHighlightColor: string;
  63016. /** Gets or sets control margin */
  63017. margin: string;
  63018. /** Gets control margin in pixels */
  63019. readonly marginInPixels: number;
  63020. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63021. autoStretchWidth: boolean;
  63022. /** Gets or sets border thickness */
  63023. thickness: number;
  63024. /** Gets or sets the background color when focused */
  63025. focusedBackground: string;
  63026. /** Gets or sets the background color when focused */
  63027. focusedColor: string;
  63028. /** Gets or sets the background color */
  63029. background: string;
  63030. /** Gets or sets the placeholder color */
  63031. placeholderColor: string;
  63032. /** Gets or sets the text displayed when the control is empty */
  63033. placeholderText: string;
  63034. /** Gets or sets the dead key flag */
  63035. deadKey: boolean;
  63036. /** Gets or sets the highlight text */
  63037. highlightedText: string;
  63038. /** Gets or sets if the current key should be added */
  63039. addKey: boolean;
  63040. /** Gets or sets the value of the current key being entered */
  63041. currentKey: string;
  63042. /** Gets or sets the text displayed in the control */
  63043. text: string;
  63044. /** Gets or sets control width */
  63045. width: string | number;
  63046. /**
  63047. * Creates a new InputText
  63048. * @param name defines the control name
  63049. * @param text defines the text of the control
  63050. */
  63051. constructor(name?: string | undefined, text?: string);
  63052. /** @hidden */
  63053. onBlur(): void;
  63054. /** @hidden */
  63055. onFocus(): void;
  63056. protected _getTypeName(): string;
  63057. /**
  63058. * Function called to get the list of controls that should not steal the focus from this control
  63059. * @returns an array of controls
  63060. */
  63061. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63062. /** @hidden */
  63063. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63064. /** @hidden */
  63065. private _updateValueFromCursorIndex;
  63066. /** @hidden */
  63067. private _processDblClick;
  63068. /** @hidden */
  63069. private _selectAllText;
  63070. /**
  63071. * Handles the keyboard event
  63072. * @param evt Defines the KeyboardEvent
  63073. */
  63074. processKeyboard(evt: KeyboardEvent): void;
  63075. /** @hidden */
  63076. private _onCopyText;
  63077. /** @hidden */
  63078. private _onCutText;
  63079. /** @hidden */
  63080. private _onPasteText;
  63081. _draw(context: CanvasRenderingContext2D): void;
  63082. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63083. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63084. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63085. protected _beforeRenderText(text: string): string;
  63086. dispose(): void;
  63087. }
  63088. }
  63089. declare module BABYLON.GUI {
  63090. /**
  63091. * Class used to create a 2D grid container
  63092. */
  63093. export class Grid extends Container {
  63094. name?: string | undefined;
  63095. private _rowDefinitions;
  63096. private _columnDefinitions;
  63097. private _cells;
  63098. private _childControls;
  63099. /**
  63100. * Gets the number of columns
  63101. */
  63102. readonly columnCount: number;
  63103. /**
  63104. * Gets the number of rows
  63105. */
  63106. readonly rowCount: number;
  63107. /** Gets the list of children */
  63108. readonly children: Control[];
  63109. /** Gets the list of cells (e.g. the containers) */
  63110. readonly cells: {
  63111. [key: string]: Container;
  63112. };
  63113. /**
  63114. * Gets the definition of a specific row
  63115. * @param index defines the index of the row
  63116. * @returns the row definition
  63117. */
  63118. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63119. /**
  63120. * Gets the definition of a specific column
  63121. * @param index defines the index of the column
  63122. * @returns the column definition
  63123. */
  63124. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63125. /**
  63126. * Adds a new row to the grid
  63127. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63128. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63129. * @returns the current grid
  63130. */
  63131. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63132. /**
  63133. * Adds a new column to the grid
  63134. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63135. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63136. * @returns the current grid
  63137. */
  63138. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63139. /**
  63140. * Update a row definition
  63141. * @param index defines the index of the row to update
  63142. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63143. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63144. * @returns the current grid
  63145. */
  63146. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63147. /**
  63148. * Update a column definition
  63149. * @param index defines the index of the column to update
  63150. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63151. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63152. * @returns the current grid
  63153. */
  63154. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63155. /**
  63156. * Gets the list of children stored in a specific cell
  63157. * @param row defines the row to check
  63158. * @param column defines the column to check
  63159. * @returns the list of controls
  63160. */
  63161. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63162. /**
  63163. * Gets a string representing the child cell info (row x column)
  63164. * @param child defines the control to get info from
  63165. * @returns a string containing the child cell info (row x column)
  63166. */
  63167. getChildCellInfo(child: Control): string;
  63168. private _removeCell;
  63169. private _offsetCell;
  63170. /**
  63171. * Remove a column definition at specified index
  63172. * @param index defines the index of the column to remove
  63173. * @returns the current grid
  63174. */
  63175. removeColumnDefinition(index: number): Grid;
  63176. /**
  63177. * Remove a row definition at specified index
  63178. * @param index defines the index of the row to remove
  63179. * @returns the current grid
  63180. */
  63181. removeRowDefinition(index: number): Grid;
  63182. /**
  63183. * Adds a new control to the current grid
  63184. * @param control defines the control to add
  63185. * @param row defines the row where to add the control (0 by default)
  63186. * @param column defines the column where to add the control (0 by default)
  63187. * @returns the current grid
  63188. */
  63189. addControl(control: Control, row?: number, column?: number): Grid;
  63190. /**
  63191. * Removes a control from the current container
  63192. * @param control defines the control to remove
  63193. * @returns the current container
  63194. */
  63195. removeControl(control: Control): Container;
  63196. /**
  63197. * Creates a new Grid
  63198. * @param name defines control name
  63199. */
  63200. constructor(name?: string | undefined);
  63201. protected _getTypeName(): string;
  63202. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63203. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63204. _flagDescendantsAsMatrixDirty(): void;
  63205. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63206. /** Releases associated resources */
  63207. dispose(): void;
  63208. }
  63209. }
  63210. declare module BABYLON.GUI {
  63211. /** Class used to create color pickers */
  63212. export class ColorPicker extends Control {
  63213. name?: string | undefined;
  63214. private static _Epsilon;
  63215. private _colorWheelCanvas;
  63216. private _value;
  63217. private _tmpColor;
  63218. private _pointerStartedOnSquare;
  63219. private _pointerStartedOnWheel;
  63220. private _squareLeft;
  63221. private _squareTop;
  63222. private _squareSize;
  63223. private _h;
  63224. private _s;
  63225. private _v;
  63226. private _lastPointerDownID;
  63227. /**
  63228. * BABYLON.Observable raised when the value changes
  63229. */
  63230. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63231. /** Gets or sets the color of the color picker */
  63232. value: BABYLON.Color3;
  63233. /**
  63234. * Gets or sets control width
  63235. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63236. */
  63237. width: string | number;
  63238. /**
  63239. * Gets or sets control height
  63240. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63241. */
  63242. /** Gets or sets control height */
  63243. height: string | number;
  63244. /** Gets or sets control size */
  63245. size: string | number;
  63246. /**
  63247. * Creates a new ColorPicker
  63248. * @param name defines the control name
  63249. */
  63250. constructor(name?: string | undefined);
  63251. protected _getTypeName(): string;
  63252. /** @hidden */
  63253. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63254. private _updateSquareProps;
  63255. private _drawGradientSquare;
  63256. private _drawCircle;
  63257. private _createColorWheelCanvas;
  63258. /** @hidden */
  63259. _draw(context: CanvasRenderingContext2D): void;
  63260. private _pointerIsDown;
  63261. private _updateValueFromPointer;
  63262. private _isPointOnSquare;
  63263. private _isPointOnWheel;
  63264. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63265. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63266. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63267. /**
  63268. * This function expands the color picker by creating a color picker dialog with manual
  63269. * color value input and the ability to save colors into an array to be used later in
  63270. * subsequent launches of the dialogue.
  63271. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63272. * @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.
  63273. * @returns picked color as a hex string and the saved colors array as hex strings.
  63274. */
  63275. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63276. pickerWidth?: string;
  63277. pickerHeight?: string;
  63278. headerHeight?: string;
  63279. lastColor?: string;
  63280. swatchLimit?: number;
  63281. numSwatchesPerLine?: number;
  63282. savedColors?: Array<string>;
  63283. }): Promise<{
  63284. savedColors?: string[];
  63285. pickedColor: string;
  63286. }>;
  63287. }
  63288. }
  63289. declare module BABYLON.GUI {
  63290. /** Class used to create 2D ellipse containers */
  63291. export class Ellipse extends Container {
  63292. name?: string | undefined;
  63293. private _thickness;
  63294. /** Gets or sets border thickness */
  63295. thickness: number;
  63296. /**
  63297. * Creates a new Ellipse
  63298. * @param name defines the control name
  63299. */
  63300. constructor(name?: string | undefined);
  63301. protected _getTypeName(): string;
  63302. protected _localDraw(context: CanvasRenderingContext2D): void;
  63303. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63304. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63305. }
  63306. }
  63307. declare module BABYLON.GUI {
  63308. /**
  63309. * Class used to create a password control
  63310. */
  63311. export class InputPassword extends InputText {
  63312. protected _beforeRenderText(text: string): string;
  63313. }
  63314. }
  63315. declare module BABYLON.GUI {
  63316. /** Class used to render 2D lines */
  63317. export class Line extends Control {
  63318. name?: string | undefined;
  63319. private _lineWidth;
  63320. private _x1;
  63321. private _y1;
  63322. private _x2;
  63323. private _y2;
  63324. private _dash;
  63325. private _connectedControl;
  63326. private _connectedControlDirtyObserver;
  63327. /** Gets or sets the dash pattern */
  63328. dash: Array<number>;
  63329. /** Gets or sets the control connected with the line end */
  63330. connectedControl: Control;
  63331. /** Gets or sets start coordinates on X axis */
  63332. x1: string | number;
  63333. /** Gets or sets start coordinates on Y axis */
  63334. y1: string | number;
  63335. /** Gets or sets end coordinates on X axis */
  63336. x2: string | number;
  63337. /** Gets or sets end coordinates on Y axis */
  63338. y2: string | number;
  63339. /** Gets or sets line width */
  63340. lineWidth: number;
  63341. /** Gets or sets horizontal alignment */
  63342. horizontalAlignment: number;
  63343. /** Gets or sets vertical alignment */
  63344. verticalAlignment: number;
  63345. private readonly _effectiveX2;
  63346. private readonly _effectiveY2;
  63347. /**
  63348. * Creates a new Line
  63349. * @param name defines the control name
  63350. */
  63351. constructor(name?: string | undefined);
  63352. protected _getTypeName(): string;
  63353. _draw(context: CanvasRenderingContext2D): void;
  63354. _measure(): void;
  63355. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63356. /**
  63357. * Move one end of the line given 3D cartesian coordinates.
  63358. * @param position Targeted world position
  63359. * @param scene BABYLON.Scene
  63360. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63361. */
  63362. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63363. /**
  63364. * Move one end of the line to a position in screen absolute space.
  63365. * @param projectedPosition Position in screen absolute space (X, Y)
  63366. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63367. */
  63368. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63369. }
  63370. }
  63371. declare module BABYLON.GUI {
  63372. /**
  63373. * Class used to store a point for a MultiLine object.
  63374. * The point can be pure 2D coordinates, a mesh or a control
  63375. */
  63376. export class MultiLinePoint {
  63377. private _multiLine;
  63378. private _x;
  63379. private _y;
  63380. private _control;
  63381. private _mesh;
  63382. private _controlObserver;
  63383. private _meshObserver;
  63384. /** @hidden */
  63385. _point: BABYLON.Vector2;
  63386. /**
  63387. * Creates a new MultiLinePoint
  63388. * @param multiLine defines the source MultiLine object
  63389. */
  63390. constructor(multiLine: MultiLine);
  63391. /** Gets or sets x coordinate */
  63392. x: string | number;
  63393. /** Gets or sets y coordinate */
  63394. y: string | number;
  63395. /** Gets or sets the control associated with this point */
  63396. control: BABYLON.Nullable<Control>;
  63397. /** Gets or sets the mesh associated with this point */
  63398. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63399. /** Resets links */
  63400. resetLinks(): void;
  63401. /**
  63402. * Gets a translation vector
  63403. * @returns the translation vector
  63404. */
  63405. translate(): BABYLON.Vector2;
  63406. private _translatePoint;
  63407. /** Release associated resources */
  63408. dispose(): void;
  63409. }
  63410. }
  63411. declare module BABYLON.GUI {
  63412. /**
  63413. * Class used to create multi line control
  63414. */
  63415. export class MultiLine extends Control {
  63416. name?: string | undefined;
  63417. private _lineWidth;
  63418. private _dash;
  63419. private _points;
  63420. private _minX;
  63421. private _minY;
  63422. private _maxX;
  63423. private _maxY;
  63424. /**
  63425. * Creates a new MultiLine
  63426. * @param name defines the control name
  63427. */
  63428. constructor(name?: string | undefined);
  63429. /** Gets or sets dash pattern */
  63430. dash: Array<number>;
  63431. /**
  63432. * Gets point stored at specified index
  63433. * @param index defines the index to look for
  63434. * @returns the requested point if found
  63435. */
  63436. getAt(index: number): MultiLinePoint;
  63437. /** Function called when a point is updated */
  63438. onPointUpdate: () => void;
  63439. /**
  63440. * Adds new points to the point collection
  63441. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63442. * @returns the list of created MultiLinePoint
  63443. */
  63444. add(...items: (AbstractMesh | Control | {
  63445. x: string | number;
  63446. y: string | number;
  63447. })[]): MultiLinePoint[];
  63448. /**
  63449. * Adds a new point to the point collection
  63450. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63451. * @returns the created MultiLinePoint
  63452. */
  63453. push(item?: (AbstractMesh | Control | {
  63454. x: string | number;
  63455. y: string | number;
  63456. })): MultiLinePoint;
  63457. /**
  63458. * Remove a specific value or point from the active point collection
  63459. * @param value defines the value or point to remove
  63460. */
  63461. remove(value: number | MultiLinePoint): void;
  63462. /**
  63463. * Resets this object to initial state (no point)
  63464. */
  63465. reset(): void;
  63466. /**
  63467. * Resets all links
  63468. */
  63469. resetLinks(): void;
  63470. /** Gets or sets line width */
  63471. lineWidth: number;
  63472. horizontalAlignment: number;
  63473. verticalAlignment: number;
  63474. protected _getTypeName(): string;
  63475. _draw(context: CanvasRenderingContext2D): void;
  63476. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63477. _measure(): void;
  63478. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63479. dispose(): void;
  63480. }
  63481. }
  63482. declare module BABYLON.GUI {
  63483. /**
  63484. * Class used to create radio button controls
  63485. */
  63486. export class RadioButton extends Control {
  63487. name?: string | undefined;
  63488. private _isChecked;
  63489. private _background;
  63490. private _checkSizeRatio;
  63491. private _thickness;
  63492. /** Gets or sets border thickness */
  63493. thickness: number;
  63494. /** Gets or sets group name */
  63495. group: string;
  63496. /** BABYLON.Observable raised when isChecked is changed */
  63497. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63498. /** Gets or sets a value indicating the ratio between overall size and check size */
  63499. checkSizeRatio: number;
  63500. /** Gets or sets background color */
  63501. background: string;
  63502. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63503. isChecked: boolean;
  63504. /**
  63505. * Creates a new RadioButton
  63506. * @param name defines the control name
  63507. */
  63508. constructor(name?: string | undefined);
  63509. protected _getTypeName(): string;
  63510. _draw(context: CanvasRenderingContext2D): void;
  63511. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63512. /**
  63513. * Utility function to easily create a radio button with a header
  63514. * @param title defines the label to use for the header
  63515. * @param group defines the group to use for the radio button
  63516. * @param isChecked defines the initial state of the radio button
  63517. * @param onValueChanged defines the callback to call when value changes
  63518. * @returns a StackPanel containing the radio button and a textBlock
  63519. */
  63520. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63521. }
  63522. }
  63523. declare module BABYLON.GUI {
  63524. /**
  63525. * Class used to create slider controls
  63526. */
  63527. export class BaseSlider extends Control {
  63528. name?: string | undefined;
  63529. protected _thumbWidth: ValueAndUnit;
  63530. private _minimum;
  63531. private _maximum;
  63532. private _value;
  63533. private _isVertical;
  63534. protected _barOffset: ValueAndUnit;
  63535. private _isThumbClamped;
  63536. protected _displayThumb: boolean;
  63537. private _step;
  63538. private _lastPointerDownID;
  63539. protected _effectiveBarOffset: number;
  63540. protected _renderLeft: number;
  63541. protected _renderTop: number;
  63542. protected _renderWidth: number;
  63543. protected _renderHeight: number;
  63544. protected _backgroundBoxLength: number;
  63545. protected _backgroundBoxThickness: number;
  63546. protected _effectiveThumbThickness: number;
  63547. /** BABYLON.Observable raised when the sldier value changes */
  63548. onValueChangedObservable: BABYLON.Observable<number>;
  63549. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63550. displayThumb: boolean;
  63551. /** Gets or sets a step to apply to values (0 by default) */
  63552. step: number;
  63553. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63554. barOffset: string | number;
  63555. /** Gets main bar offset in pixels*/
  63556. readonly barOffsetInPixels: number;
  63557. /** Gets or sets thumb width */
  63558. thumbWidth: string | number;
  63559. /** Gets thumb width in pixels */
  63560. readonly thumbWidthInPixels: number;
  63561. /** Gets or sets minimum value */
  63562. minimum: number;
  63563. /** Gets or sets maximum value */
  63564. maximum: number;
  63565. /** Gets or sets current value */
  63566. value: number;
  63567. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63568. isVertical: boolean;
  63569. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63570. isThumbClamped: boolean;
  63571. /**
  63572. * Creates a new BaseSlider
  63573. * @param name defines the control name
  63574. */
  63575. constructor(name?: string | undefined);
  63576. protected _getTypeName(): string;
  63577. protected _getThumbPosition(): number;
  63578. protected _getThumbThickness(type: string): number;
  63579. protected _prepareRenderingData(type: string): void;
  63580. private _pointerIsDown;
  63581. /** @hidden */
  63582. protected _updateValueFromPointer(x: number, y: number): void;
  63583. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63584. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63585. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63586. }
  63587. }
  63588. declare module BABYLON.GUI {
  63589. /**
  63590. * Class used to create slider controls
  63591. */
  63592. export class Slider extends BaseSlider {
  63593. name?: string | undefined;
  63594. private _background;
  63595. private _borderColor;
  63596. private _isThumbCircle;
  63597. protected _displayValueBar: boolean;
  63598. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63599. displayValueBar: boolean;
  63600. /** Gets or sets border color */
  63601. borderColor: string;
  63602. /** Gets or sets background color */
  63603. background: string;
  63604. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63605. isThumbCircle: boolean;
  63606. /**
  63607. * Creates a new Slider
  63608. * @param name defines the control name
  63609. */
  63610. constructor(name?: string | undefined);
  63611. protected _getTypeName(): string;
  63612. _draw(context: CanvasRenderingContext2D): void;
  63613. }
  63614. }
  63615. declare module BABYLON.GUI {
  63616. /** Class used to create a RadioGroup
  63617. * which contains groups of radio buttons
  63618. */
  63619. export class SelectorGroup {
  63620. /** name of SelectorGroup */
  63621. name: string;
  63622. private _groupPanel;
  63623. private _selectors;
  63624. private _groupHeader;
  63625. /**
  63626. * Creates a new SelectorGroup
  63627. * @param name of group, used as a group heading
  63628. */
  63629. constructor(
  63630. /** name of SelectorGroup */
  63631. name: string);
  63632. /** Gets the groupPanel of the SelectorGroup */
  63633. readonly groupPanel: StackPanel;
  63634. /** Gets the selectors array */
  63635. readonly selectors: StackPanel[];
  63636. /** Gets and sets the group header */
  63637. header: string;
  63638. /** @hidden */
  63639. private _addGroupHeader;
  63640. /** @hidden*/
  63641. _getSelector(selectorNb: number): StackPanel | undefined;
  63642. /** Removes the selector at the given position
  63643. * @param selectorNb the position of the selector within the group
  63644. */
  63645. removeSelector(selectorNb: number): void;
  63646. }
  63647. /** Class used to create a CheckboxGroup
  63648. * which contains groups of checkbox buttons
  63649. */
  63650. export class CheckboxGroup extends SelectorGroup {
  63651. /** Adds a checkbox as a control
  63652. * @param text is the label for the selector
  63653. * @param func is the function called when the Selector is checked
  63654. * @param checked is true when Selector is checked
  63655. */
  63656. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63657. /** @hidden */
  63658. _setSelectorLabel(selectorNb: number, label: string): void;
  63659. /** @hidden */
  63660. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63661. /** @hidden */
  63662. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63663. /** @hidden */
  63664. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63665. }
  63666. /** Class used to create a RadioGroup
  63667. * which contains groups of radio buttons
  63668. */
  63669. export class RadioGroup extends SelectorGroup {
  63670. private _selectNb;
  63671. /** Adds a radio button as a control
  63672. * @param label is the label for the selector
  63673. * @param func is the function called when the Selector is checked
  63674. * @param checked is true when Selector is checked
  63675. */
  63676. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63677. /** @hidden */
  63678. _setSelectorLabel(selectorNb: number, label: string): void;
  63679. /** @hidden */
  63680. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63681. /** @hidden */
  63682. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63683. /** @hidden */
  63684. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63685. }
  63686. /** Class used to create a SliderGroup
  63687. * which contains groups of slider buttons
  63688. */
  63689. export class SliderGroup extends SelectorGroup {
  63690. /**
  63691. * Adds a slider to the SelectorGroup
  63692. * @param label is the label for the SliderBar
  63693. * @param func is the function called when the Slider moves
  63694. * @param unit is a string describing the units used, eg degrees or metres
  63695. * @param min is the minimum value for the Slider
  63696. * @param max is the maximum value for the Slider
  63697. * @param value is the start value for the Slider between min and max
  63698. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63699. */
  63700. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  63701. /** @hidden */
  63702. _setSelectorLabel(selectorNb: number, label: string): void;
  63703. /** @hidden */
  63704. _setSelectorLabelColor(selectorNb: number, color: string): void;
  63705. /** @hidden */
  63706. _setSelectorButtonColor(selectorNb: number, color: string): void;
  63707. /** @hidden */
  63708. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63709. }
  63710. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  63711. * @see http://doc.babylonjs.com/how_to/selector
  63712. */
  63713. export class SelectionPanel extends Rectangle {
  63714. /** name of SelectionPanel */
  63715. name: string;
  63716. /** an array of SelectionGroups */
  63717. groups: SelectorGroup[];
  63718. private _panel;
  63719. private _buttonColor;
  63720. private _buttonBackground;
  63721. private _headerColor;
  63722. private _barColor;
  63723. private _barHeight;
  63724. private _spacerHeight;
  63725. private _labelColor;
  63726. private _groups;
  63727. private _bars;
  63728. /**
  63729. * Creates a new SelectionPanel
  63730. * @param name of SelectionPanel
  63731. * @param groups is an array of SelectionGroups
  63732. */
  63733. constructor(
  63734. /** name of SelectionPanel */
  63735. name: string,
  63736. /** an array of SelectionGroups */
  63737. groups?: SelectorGroup[]);
  63738. protected _getTypeName(): string;
  63739. /** Gets or sets the headerColor */
  63740. headerColor: string;
  63741. private _setHeaderColor;
  63742. /** Gets or sets the button color */
  63743. buttonColor: string;
  63744. private _setbuttonColor;
  63745. /** Gets or sets the label color */
  63746. labelColor: string;
  63747. private _setLabelColor;
  63748. /** Gets or sets the button background */
  63749. buttonBackground: string;
  63750. private _setButtonBackground;
  63751. /** Gets or sets the color of separator bar */
  63752. barColor: string;
  63753. private _setBarColor;
  63754. /** Gets or sets the height of separator bar */
  63755. barHeight: string;
  63756. private _setBarHeight;
  63757. /** Gets or sets the height of spacers*/
  63758. spacerHeight: string;
  63759. private _setSpacerHeight;
  63760. /** Adds a bar between groups */
  63761. private _addSpacer;
  63762. /** Add a group to the selection panel
  63763. * @param group is the selector group to add
  63764. */
  63765. addGroup(group: SelectorGroup): void;
  63766. /** Remove the group from the given position
  63767. * @param groupNb is the position of the group in the list
  63768. */
  63769. removeGroup(groupNb: number): void;
  63770. /** Change a group header label
  63771. * @param label is the new group header label
  63772. * @param groupNb is the number of the group to relabel
  63773. * */
  63774. setHeaderName(label: string, groupNb: number): void;
  63775. /** Change selector label to the one given
  63776. * @param label is the new selector label
  63777. * @param groupNb is the number of the groupcontaining the selector
  63778. * @param selectorNb is the number of the selector within a group to relabel
  63779. * */
  63780. relabel(label: string, groupNb: number, selectorNb: number): void;
  63781. /** For a given group position remove the selector at the given position
  63782. * @param groupNb is the number of the group to remove the selector from
  63783. * @param selectorNb is the number of the selector within the group
  63784. */
  63785. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63786. /** For a given group position of correct type add a checkbox button
  63787. * @param groupNb is the number of the group to remove the selector from
  63788. * @param label is the label for the selector
  63789. * @param func is the function called when the Selector is checked
  63790. * @param checked is true when Selector is checked
  63791. */
  63792. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63793. /** For a given group position of correct type add a radio button
  63794. * @param groupNb is the number of the group to remove the selector from
  63795. * @param label is the label for the selector
  63796. * @param func is the function called when the Selector is checked
  63797. * @param checked is true when Selector is checked
  63798. */
  63799. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63800. /**
  63801. * For a given slider group add a slider
  63802. * @param groupNb is the number of the group to add the slider to
  63803. * @param label is the label for the Slider
  63804. * @param func is the function called when the Slider moves
  63805. * @param unit is a string describing the units used, eg degrees or metres
  63806. * @param min is the minimum value for the Slider
  63807. * @param max is the maximum value for the Slider
  63808. * @param value is the start value for the Slider between min and max
  63809. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63810. */
  63811. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63812. }
  63813. }
  63814. declare module BABYLON.GUI {
  63815. /**
  63816. * Class used to hold a the container for ScrollViewer
  63817. * @hidden
  63818. */
  63819. export class _ScrollViewerWindow extends Container {
  63820. parentClientWidth: number;
  63821. parentClientHeight: number;
  63822. /**
  63823. * Creates a new ScrollViewerWindow
  63824. * @param name of ScrollViewerWindow
  63825. */
  63826. constructor(name?: string);
  63827. protected _getTypeName(): string;
  63828. /** @hidden */
  63829. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63830. protected _postMeasure(): void;
  63831. }
  63832. }
  63833. declare module BABYLON.GUI {
  63834. /**
  63835. * Class used to create slider controls
  63836. */
  63837. export class ScrollBar extends BaseSlider {
  63838. name?: string | undefined;
  63839. private _background;
  63840. private _borderColor;
  63841. private _thumbMeasure;
  63842. /** Gets or sets border color */
  63843. borderColor: string;
  63844. /** Gets or sets background color */
  63845. background: string;
  63846. /**
  63847. * Creates a new Slider
  63848. * @param name defines the control name
  63849. */
  63850. constructor(name?: string | undefined);
  63851. protected _getTypeName(): string;
  63852. protected _getThumbThickness(): number;
  63853. _draw(context: CanvasRenderingContext2D): void;
  63854. private _first;
  63855. private _originX;
  63856. private _originY;
  63857. /** @hidden */
  63858. protected _updateValueFromPointer(x: number, y: number): void;
  63859. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63860. }
  63861. }
  63862. declare module BABYLON.GUI {
  63863. /**
  63864. * Class used to hold a viewer window and sliders in a grid
  63865. */
  63866. export class ScrollViewer extends Rectangle {
  63867. private _grid;
  63868. private _horizontalBarSpace;
  63869. private _verticalBarSpace;
  63870. private _dragSpace;
  63871. private _horizontalBar;
  63872. private _verticalBar;
  63873. private _barColor;
  63874. private _barBackground;
  63875. private _barSize;
  63876. private _endLeft;
  63877. private _endTop;
  63878. private _window;
  63879. private _pointerIsOver;
  63880. private _wheelPrecision;
  63881. private _onPointerObserver;
  63882. private _clientWidth;
  63883. private _clientHeight;
  63884. /**
  63885. * Gets the horizontal scrollbar
  63886. */
  63887. readonly horizontalBar: ScrollBar;
  63888. /**
  63889. * Gets the vertical scrollbar
  63890. */
  63891. readonly verticalBar: ScrollBar;
  63892. /**
  63893. * Adds a new control to the current container
  63894. * @param control defines the control to add
  63895. * @returns the current container
  63896. */
  63897. addControl(control: BABYLON.Nullable<Control>): Container;
  63898. /**
  63899. * Removes a control from the current container
  63900. * @param control defines the control to remove
  63901. * @returns the current container
  63902. */
  63903. removeControl(control: Control): Container;
  63904. /** Gets the list of children */
  63905. readonly children: Control[];
  63906. _flagDescendantsAsMatrixDirty(): void;
  63907. /**
  63908. * Creates a new ScrollViewer
  63909. * @param name of ScrollViewer
  63910. */
  63911. constructor(name?: string);
  63912. /** Reset the scroll viewer window to initial size */
  63913. resetWindow(): void;
  63914. protected _getTypeName(): string;
  63915. private _buildClientSizes;
  63916. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63917. protected _postMeasure(): void;
  63918. /**
  63919. * Gets or sets the mouse wheel precision
  63920. * from 0 to 1 with a default value of 0.05
  63921. * */
  63922. wheelPrecision: number;
  63923. /** Gets or sets the bar color */
  63924. barColor: string;
  63925. /** Gets or sets the size of the bar */
  63926. barSize: number;
  63927. /** Gets or sets the bar background */
  63928. barBackground: string;
  63929. /** @hidden */
  63930. private _updateScroller;
  63931. _link(host: AdvancedDynamicTexture): void;
  63932. /** @hidden */
  63933. private _attachWheel;
  63934. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63935. /** Releases associated resources */
  63936. dispose(): void;
  63937. }
  63938. }
  63939. declare module BABYLON.GUI {
  63940. /** Class used to render a grid */
  63941. export class DisplayGrid extends Control {
  63942. name?: string | undefined;
  63943. private _cellWidth;
  63944. private _cellHeight;
  63945. private _minorLineTickness;
  63946. private _minorLineColor;
  63947. private _majorLineTickness;
  63948. private _majorLineColor;
  63949. private _majorLineFrequency;
  63950. private _background;
  63951. private _displayMajorLines;
  63952. private _displayMinorLines;
  63953. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63954. displayMinorLines: boolean;
  63955. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63956. displayMajorLines: boolean;
  63957. /** Gets or sets background color (Black by default) */
  63958. background: string;
  63959. /** Gets or sets the width of each cell (20 by default) */
  63960. cellWidth: number;
  63961. /** Gets or sets the height of each cell (20 by default) */
  63962. cellHeight: number;
  63963. /** Gets or sets the tickness of minor lines (1 by default) */
  63964. minorLineTickness: number;
  63965. /** Gets or sets the color of minor lines (DarkGray by default) */
  63966. minorLineColor: string;
  63967. /** Gets or sets the tickness of major lines (2 by default) */
  63968. majorLineTickness: number;
  63969. /** Gets or sets the color of major lines (White by default) */
  63970. majorLineColor: string;
  63971. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63972. majorLineFrequency: number;
  63973. /**
  63974. * Creates a new GridDisplayRectangle
  63975. * @param name defines the control name
  63976. */
  63977. constructor(name?: string | undefined);
  63978. _draw(context: CanvasRenderingContext2D): void;
  63979. protected _getTypeName(): string;
  63980. }
  63981. }
  63982. declare module BABYLON.GUI {
  63983. /**
  63984. * Class used to create slider controls based on images
  63985. */
  63986. export class ImageBasedSlider extends BaseSlider {
  63987. name?: string | undefined;
  63988. private _backgroundImage;
  63989. private _thumbImage;
  63990. private _valueBarImage;
  63991. private _tempMeasure;
  63992. displayThumb: boolean;
  63993. /**
  63994. * Gets or sets the image used to render the background
  63995. */
  63996. backgroundImage: Image;
  63997. /**
  63998. * Gets or sets the image used to render the value bar
  63999. */
  64000. valueBarImage: Image;
  64001. /**
  64002. * Gets or sets the image used to render the thumb
  64003. */
  64004. thumbImage: Image;
  64005. /**
  64006. * Creates a new ImageBasedSlider
  64007. * @param name defines the control name
  64008. */
  64009. constructor(name?: string | undefined);
  64010. protected _getTypeName(): string;
  64011. _draw(context: CanvasRenderingContext2D): void;
  64012. }
  64013. }
  64014. declare module BABYLON.GUI {
  64015. /**
  64016. * Forcing an export so that this code will execute
  64017. * @hidden
  64018. */
  64019. const name = "Statics";
  64020. }
  64021. declare module BABYLON.GUI {
  64022. /**
  64023. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64024. */
  64025. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64026. /**
  64027. * Define the instrumented AdvancedDynamicTexture.
  64028. */
  64029. texture: AdvancedDynamicTexture;
  64030. private _captureRenderTime;
  64031. private _renderTime;
  64032. private _captureLayoutTime;
  64033. private _layoutTime;
  64034. private _onBeginRenderObserver;
  64035. private _onEndRenderObserver;
  64036. private _onBeginLayoutObserver;
  64037. private _onEndLayoutObserver;
  64038. /**
  64039. * Gets the perf counter used to capture render time
  64040. */
  64041. readonly renderTimeCounter: BABYLON.PerfCounter;
  64042. /**
  64043. * Gets the perf counter used to capture layout time
  64044. */
  64045. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64046. /**
  64047. * Enable or disable the render time capture
  64048. */
  64049. captureRenderTime: boolean;
  64050. /**
  64051. * Enable or disable the layout time capture
  64052. */
  64053. captureLayoutTime: boolean;
  64054. /**
  64055. * Instantiates a new advanced dynamic texture instrumentation.
  64056. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64057. * @param texture Defines the AdvancedDynamicTexture to instrument
  64058. */
  64059. constructor(
  64060. /**
  64061. * Define the instrumented AdvancedDynamicTexture.
  64062. */
  64063. texture: AdvancedDynamicTexture);
  64064. /**
  64065. * Dispose and release associated resources.
  64066. */
  64067. dispose(): void;
  64068. }
  64069. }
  64070. declare module BABYLON.GUI {
  64071. /**
  64072. * Class used to create containers for controls
  64073. */
  64074. export class Container3D extends Control3D {
  64075. private _blockLayout;
  64076. /**
  64077. * Gets the list of child controls
  64078. */
  64079. protected _children: Control3D[];
  64080. /**
  64081. * Gets the list of child controls
  64082. */
  64083. readonly children: Array<Control3D>;
  64084. /**
  64085. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64086. * This is helpful to optimize layout operation when adding multiple children in a row
  64087. */
  64088. blockLayout: boolean;
  64089. /**
  64090. * Creates a new container
  64091. * @param name defines the container name
  64092. */
  64093. constructor(name?: string);
  64094. /**
  64095. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64096. * @returns the current container
  64097. */
  64098. updateLayout(): Container3D;
  64099. /**
  64100. * Gets a boolean indicating if the given control is in the children of this control
  64101. * @param control defines the control to check
  64102. * @returns true if the control is in the child list
  64103. */
  64104. containsControl(control: Control3D): boolean;
  64105. /**
  64106. * Adds a control to the children of this control
  64107. * @param control defines the control to add
  64108. * @returns the current container
  64109. */
  64110. addControl(control: Control3D): Container3D;
  64111. /**
  64112. * This function will be called everytime a new control is added
  64113. */
  64114. protected _arrangeChildren(): void;
  64115. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64116. /**
  64117. * Removes a control from the children of this control
  64118. * @param control defines the control to remove
  64119. * @returns the current container
  64120. */
  64121. removeControl(control: Control3D): Container3D;
  64122. protected _getTypeName(): string;
  64123. /**
  64124. * Releases all associated resources
  64125. */
  64126. dispose(): void;
  64127. /** Control rotation will remain unchanged */
  64128. static readonly UNSET_ORIENTATION: number;
  64129. /** Control will rotate to make it look at sphere central axis */
  64130. static readonly FACEORIGIN_ORIENTATION: number;
  64131. /** Control will rotate to make it look back at sphere central axis */
  64132. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64133. /** Control will rotate to look at z axis (0, 0, 1) */
  64134. static readonly FACEFORWARD_ORIENTATION: number;
  64135. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64136. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64137. }
  64138. }
  64139. declare module BABYLON.GUI {
  64140. /**
  64141. * Class used to manage 3D user interface
  64142. * @see http://doc.babylonjs.com/how_to/gui3d
  64143. */
  64144. export class GUI3DManager implements BABYLON.IDisposable {
  64145. private _scene;
  64146. private _sceneDisposeObserver;
  64147. private _utilityLayer;
  64148. private _rootContainer;
  64149. private _pointerObserver;
  64150. private _pointerOutObserver;
  64151. /** @hidden */
  64152. _lastPickedControl: Control3D;
  64153. /** @hidden */
  64154. _lastControlOver: {
  64155. [pointerId: number]: Control3D;
  64156. };
  64157. /** @hidden */
  64158. _lastControlDown: {
  64159. [pointerId: number]: Control3D;
  64160. };
  64161. /**
  64162. * BABYLON.Observable raised when the point picked by the pointer events changed
  64163. */
  64164. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64165. /** @hidden */
  64166. _sharedMaterials: {
  64167. [key: string]: BABYLON.Material;
  64168. };
  64169. /** Gets the hosting scene */
  64170. readonly scene: BABYLON.Scene;
  64171. /** Gets associated utility layer */
  64172. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64173. /**
  64174. * Creates a new GUI3DManager
  64175. * @param scene
  64176. */
  64177. constructor(scene?: BABYLON.Scene);
  64178. private _handlePointerOut;
  64179. private _doPicking;
  64180. /**
  64181. * Gets the root container
  64182. */
  64183. readonly rootContainer: Container3D;
  64184. /**
  64185. * Gets a boolean indicating if the given control is in the root child list
  64186. * @param control defines the control to check
  64187. * @returns true if the control is in the root child list
  64188. */
  64189. containsControl(control: Control3D): boolean;
  64190. /**
  64191. * Adds a control to the root child list
  64192. * @param control defines the control to add
  64193. * @returns the current manager
  64194. */
  64195. addControl(control: Control3D): GUI3DManager;
  64196. /**
  64197. * Removes a control from the root child list
  64198. * @param control defines the control to remove
  64199. * @returns the current container
  64200. */
  64201. removeControl(control: Control3D): GUI3DManager;
  64202. /**
  64203. * Releases all associated resources
  64204. */
  64205. dispose(): void;
  64206. }
  64207. }
  64208. declare module BABYLON.GUI {
  64209. /**
  64210. * Class used to transport BABYLON.Vector3 information for pointer events
  64211. */
  64212. export class Vector3WithInfo extends BABYLON.Vector3 {
  64213. /** defines the current mouse button index */
  64214. buttonIndex: number;
  64215. /**
  64216. * Creates a new Vector3WithInfo
  64217. * @param source defines the vector3 data to transport
  64218. * @param buttonIndex defines the current mouse button index
  64219. */
  64220. constructor(source: BABYLON.Vector3,
  64221. /** defines the current mouse button index */
  64222. buttonIndex?: number);
  64223. }
  64224. }
  64225. declare module BABYLON.GUI {
  64226. /**
  64227. * Class used as base class for controls
  64228. */
  64229. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64230. /** Defines the control name */
  64231. name?: string | undefined;
  64232. /** @hidden */
  64233. _host: GUI3DManager;
  64234. private _node;
  64235. private _downCount;
  64236. private _enterCount;
  64237. private _downPointerIds;
  64238. private _isVisible;
  64239. /** Gets or sets the control position in world space */
  64240. position: BABYLON.Vector3;
  64241. /** Gets or sets the control scaling in world space */
  64242. scaling: BABYLON.Vector3;
  64243. /** Callback used to start pointer enter animation */
  64244. pointerEnterAnimation: () => void;
  64245. /** Callback used to start pointer out animation */
  64246. pointerOutAnimation: () => void;
  64247. /** Callback used to start pointer down animation */
  64248. pointerDownAnimation: () => void;
  64249. /** Callback used to start pointer up animation */
  64250. pointerUpAnimation: () => void;
  64251. /**
  64252. * An event triggered when the pointer move over the control
  64253. */
  64254. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64255. /**
  64256. * An event triggered when the pointer move out of the control
  64257. */
  64258. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64259. /**
  64260. * An event triggered when the pointer taps the control
  64261. */
  64262. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64263. /**
  64264. * An event triggered when pointer is up
  64265. */
  64266. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64267. /**
  64268. * An event triggered when a control is clicked on (with a mouse)
  64269. */
  64270. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64271. /**
  64272. * An event triggered when pointer enters the control
  64273. */
  64274. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64275. /**
  64276. * Gets or sets the parent container
  64277. */
  64278. parent: BABYLON.Nullable<Container3D>;
  64279. private _behaviors;
  64280. /**
  64281. * Gets the list of attached behaviors
  64282. * @see http://doc.babylonjs.com/features/behaviour
  64283. */
  64284. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64285. /**
  64286. * Attach a behavior to the control
  64287. * @see http://doc.babylonjs.com/features/behaviour
  64288. * @param behavior defines the behavior to attach
  64289. * @returns the current control
  64290. */
  64291. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64292. /**
  64293. * Remove an attached behavior
  64294. * @see http://doc.babylonjs.com/features/behaviour
  64295. * @param behavior defines the behavior to attach
  64296. * @returns the current control
  64297. */
  64298. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64299. /**
  64300. * Gets an attached behavior by name
  64301. * @param name defines the name of the behavior to look for
  64302. * @see http://doc.babylonjs.com/features/behaviour
  64303. * @returns null if behavior was not found else the requested behavior
  64304. */
  64305. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64306. /** Gets or sets a boolean indicating if the control is visible */
  64307. isVisible: boolean;
  64308. /**
  64309. * Creates a new control
  64310. * @param name defines the control name
  64311. */
  64312. constructor(
  64313. /** Defines the control name */
  64314. name?: string | undefined);
  64315. /**
  64316. * Gets a string representing the class name
  64317. */
  64318. readonly typeName: string;
  64319. /**
  64320. * Get the current class name of the control.
  64321. * @returns current class name
  64322. */
  64323. getClassName(): string;
  64324. protected _getTypeName(): string;
  64325. /**
  64326. * Gets the transform node used by this control
  64327. */
  64328. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64329. /**
  64330. * Gets the mesh used to render this control
  64331. */
  64332. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64333. /**
  64334. * Link the control as child of the given node
  64335. * @param node defines the node to link to. Use null to unlink the control
  64336. * @returns the current control
  64337. */
  64338. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64339. /** @hidden **/
  64340. _prepareNode(scene: BABYLON.Scene): void;
  64341. /**
  64342. * Node creation.
  64343. * Can be overriden by children
  64344. * @param scene defines the scene where the node must be attached
  64345. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64346. */
  64347. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64348. /**
  64349. * Affect a material to the given mesh
  64350. * @param mesh defines the mesh which will represent the control
  64351. */
  64352. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64353. /** @hidden */
  64354. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64355. /** @hidden */
  64356. _onPointerEnter(target: Control3D): boolean;
  64357. /** @hidden */
  64358. _onPointerOut(target: Control3D): void;
  64359. /** @hidden */
  64360. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64361. /** @hidden */
  64362. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64363. /** @hidden */
  64364. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64365. /** @hidden */
  64366. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64367. /** @hidden */
  64368. _disposeNode(): void;
  64369. /**
  64370. * Releases all associated resources
  64371. */
  64372. dispose(): void;
  64373. }
  64374. }
  64375. declare module BABYLON.GUI {
  64376. /**
  64377. * Class used as a root to all buttons
  64378. */
  64379. export class AbstractButton3D extends Control3D {
  64380. /**
  64381. * Creates a new button
  64382. * @param name defines the control name
  64383. */
  64384. constructor(name?: string);
  64385. protected _getTypeName(): string;
  64386. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64387. }
  64388. }
  64389. declare module BABYLON.GUI {
  64390. /**
  64391. * Class used to create a button in 3D
  64392. */
  64393. export class Button3D extends AbstractButton3D {
  64394. /** @hidden */
  64395. protected _currentMaterial: BABYLON.Material;
  64396. private _facadeTexture;
  64397. private _content;
  64398. private _contentResolution;
  64399. private _contentScaleRatio;
  64400. /**
  64401. * Gets or sets the texture resolution used to render content (512 by default)
  64402. */
  64403. contentResolution: BABYLON.int;
  64404. /**
  64405. * Gets or sets the texture scale ratio used to render content (2 by default)
  64406. */
  64407. contentScaleRatio: number;
  64408. protected _disposeFacadeTexture(): void;
  64409. protected _resetContent(): void;
  64410. /**
  64411. * Creates a new button
  64412. * @param name defines the control name
  64413. */
  64414. constructor(name?: string);
  64415. /**
  64416. * Gets or sets the GUI 2D content used to display the button's facade
  64417. */
  64418. content: Control;
  64419. /**
  64420. * Apply the facade texture (created from the content property).
  64421. * This function can be overloaded by child classes
  64422. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64423. */
  64424. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64425. protected _getTypeName(): string;
  64426. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64427. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64428. /**
  64429. * Releases all associated resources
  64430. */
  64431. dispose(): void;
  64432. }
  64433. }
  64434. declare module BABYLON.GUI {
  64435. /**
  64436. * Abstract class used to create a container panel deployed on the surface of a volume
  64437. */
  64438. export abstract class VolumeBasedPanel extends Container3D {
  64439. private _columns;
  64440. private _rows;
  64441. private _rowThenColum;
  64442. private _orientation;
  64443. protected _cellWidth: number;
  64444. protected _cellHeight: number;
  64445. /**
  64446. * Gets or sets the distance between elements
  64447. */
  64448. margin: number;
  64449. /**
  64450. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64451. * | Value | Type | Description |
  64452. * | ----- | ----------------------------------- | ----------- |
  64453. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64454. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64455. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64456. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64457. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64458. */
  64459. orientation: number;
  64460. /**
  64461. * Gets or sets the number of columns requested (10 by default).
  64462. * The panel will automatically compute the number of rows based on number of child controls.
  64463. */
  64464. columns: BABYLON.int;
  64465. /**
  64466. * Gets or sets a the number of rows requested.
  64467. * The panel will automatically compute the number of columns based on number of child controls.
  64468. */
  64469. rows: BABYLON.int;
  64470. /**
  64471. * Creates new VolumeBasedPanel
  64472. */
  64473. constructor();
  64474. protected _arrangeChildren(): void;
  64475. /** Child classes must implement this function to provide correct control positioning */
  64476. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64477. /** Child classes can implement this function to provide additional processing */
  64478. protected _finalProcessing(): void;
  64479. }
  64480. }
  64481. declare module BABYLON.GUI {
  64482. /**
  64483. * Class used to create a container panel deployed on the surface of a cylinder
  64484. */
  64485. export class CylinderPanel extends VolumeBasedPanel {
  64486. private _radius;
  64487. /**
  64488. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64489. */
  64490. radius: BABYLON.float;
  64491. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64492. private _cylindricalMapping;
  64493. }
  64494. }
  64495. declare module BABYLON.GUI {
  64496. /** @hidden */
  64497. export var fluentVertexShader: {
  64498. name: string;
  64499. shader: string;
  64500. };
  64501. }
  64502. declare module BABYLON.GUI {
  64503. /** @hidden */
  64504. export var fluentPixelShader: {
  64505. name: string;
  64506. shader: string;
  64507. };
  64508. }
  64509. declare module BABYLON.GUI {
  64510. /** @hidden */
  64511. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64512. INNERGLOW: boolean;
  64513. BORDER: boolean;
  64514. HOVERLIGHT: boolean;
  64515. TEXTURE: boolean;
  64516. constructor();
  64517. }
  64518. /**
  64519. * Class used to render controls with fluent desgin
  64520. */
  64521. export class FluentMaterial extends BABYLON.PushMaterial {
  64522. /**
  64523. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64524. */
  64525. innerGlowColorIntensity: number;
  64526. /**
  64527. * Gets or sets the inner glow color (white by default)
  64528. */
  64529. innerGlowColor: BABYLON.Color3;
  64530. /**
  64531. * Gets or sets alpha value (default is 1.0)
  64532. */
  64533. alpha: number;
  64534. /**
  64535. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64536. */
  64537. albedoColor: BABYLON.Color3;
  64538. /**
  64539. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64540. */
  64541. renderBorders: boolean;
  64542. /**
  64543. * Gets or sets border width (default is 0.5)
  64544. */
  64545. borderWidth: number;
  64546. /**
  64547. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64548. */
  64549. edgeSmoothingValue: number;
  64550. /**
  64551. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64552. */
  64553. borderMinValue: number;
  64554. /**
  64555. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64556. */
  64557. renderHoverLight: boolean;
  64558. /**
  64559. * Gets or sets the radius used to render the hover light (default is 1.0)
  64560. */
  64561. hoverRadius: number;
  64562. /**
  64563. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64564. */
  64565. hoverColor: BABYLON.Color4;
  64566. /**
  64567. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64568. */
  64569. hoverPosition: BABYLON.Vector3;
  64570. private _albedoTexture;
  64571. /** Gets or sets the texture to use for albedo color */
  64572. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64573. /**
  64574. * Creates a new Fluent material
  64575. * @param name defines the name of the material
  64576. * @param scene defines the hosting scene
  64577. */
  64578. constructor(name: string, scene: BABYLON.Scene);
  64579. needAlphaBlending(): boolean;
  64580. needAlphaTesting(): boolean;
  64581. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64582. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64583. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64584. getActiveTextures(): BABYLON.BaseTexture[];
  64585. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64586. dispose(forceDisposeEffect?: boolean): void;
  64587. clone(name: string): FluentMaterial;
  64588. serialize(): any;
  64589. getClassName(): string;
  64590. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64591. }
  64592. }
  64593. declare module BABYLON.GUI {
  64594. /**
  64595. * Class used to create a holographic button in 3D
  64596. */
  64597. export class HolographicButton extends Button3D {
  64598. private _backPlate;
  64599. private _textPlate;
  64600. private _frontPlate;
  64601. private _text;
  64602. private _imageUrl;
  64603. private _shareMaterials;
  64604. private _frontMaterial;
  64605. private _backMaterial;
  64606. private _plateMaterial;
  64607. private _pickedPointObserver;
  64608. private _tooltipFade;
  64609. private _tooltipTextBlock;
  64610. private _tooltipTexture;
  64611. private _tooltipMesh;
  64612. private _tooltipHoverObserver;
  64613. private _tooltipOutObserver;
  64614. private _disposeTooltip;
  64615. /**
  64616. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64617. */
  64618. tooltipText: BABYLON.Nullable<string>;
  64619. /**
  64620. * Gets or sets text for the button
  64621. */
  64622. text: string;
  64623. /**
  64624. * Gets or sets the image url for the button
  64625. */
  64626. imageUrl: string;
  64627. /**
  64628. * Gets the back material used by this button
  64629. */
  64630. readonly backMaterial: FluentMaterial;
  64631. /**
  64632. * Gets the front material used by this button
  64633. */
  64634. readonly frontMaterial: FluentMaterial;
  64635. /**
  64636. * Gets the plate material used by this button
  64637. */
  64638. readonly plateMaterial: BABYLON.StandardMaterial;
  64639. /**
  64640. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64641. */
  64642. readonly shareMaterials: boolean;
  64643. /**
  64644. * Creates a new button
  64645. * @param name defines the control name
  64646. */
  64647. constructor(name?: string, shareMaterials?: boolean);
  64648. protected _getTypeName(): string;
  64649. private _rebuildContent;
  64650. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64651. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64652. private _createBackMaterial;
  64653. private _createFrontMaterial;
  64654. private _createPlateMaterial;
  64655. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64656. /**
  64657. * Releases all associated resources
  64658. */
  64659. dispose(): void;
  64660. }
  64661. }
  64662. declare module BABYLON.GUI {
  64663. /**
  64664. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64665. */
  64666. export class MeshButton3D extends Button3D {
  64667. /** @hidden */
  64668. protected _currentMesh: BABYLON.Mesh;
  64669. /**
  64670. * Creates a new 3D button based on a mesh
  64671. * @param mesh mesh to become a 3D button
  64672. * @param name defines the control name
  64673. */
  64674. constructor(mesh: BABYLON.Mesh, name?: string);
  64675. protected _getTypeName(): string;
  64676. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64677. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64678. }
  64679. }
  64680. declare module BABYLON.GUI {
  64681. /**
  64682. * Class used to create a container panel deployed on the surface of a plane
  64683. */
  64684. export class PlanePanel extends VolumeBasedPanel {
  64685. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64686. }
  64687. }
  64688. declare module BABYLON.GUI {
  64689. /**
  64690. * Class used to create a container panel where items get randomized planar mapping
  64691. */
  64692. export class ScatterPanel extends VolumeBasedPanel {
  64693. private _iteration;
  64694. /**
  64695. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64696. */
  64697. iteration: BABYLON.float;
  64698. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64699. private _scatterMapping;
  64700. protected _finalProcessing(): void;
  64701. }
  64702. }
  64703. declare module BABYLON.GUI {
  64704. /**
  64705. * Class used to create a container panel deployed on the surface of a sphere
  64706. */
  64707. export class SpherePanel extends VolumeBasedPanel {
  64708. private _radius;
  64709. /**
  64710. * Gets or sets the radius of the sphere where to project controls (5 by default)
  64711. */
  64712. radius: BABYLON.float;
  64713. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64714. private _sphericalMapping;
  64715. }
  64716. }
  64717. declare module BABYLON.GUI {
  64718. /**
  64719. * Class used to create a stack panel in 3D on XY plane
  64720. */
  64721. export class StackPanel3D extends Container3D {
  64722. private _isVertical;
  64723. /**
  64724. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  64725. */
  64726. isVertical: boolean;
  64727. /**
  64728. * Gets or sets the distance between elements
  64729. */
  64730. margin: number;
  64731. /**
  64732. * Creates new StackPanel
  64733. * @param isVertical
  64734. */
  64735. constructor(isVertical?: boolean);
  64736. protected _arrangeChildren(): void;
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /**
  64741. * Mode that determines the coordinate system to use.
  64742. */
  64743. export enum GLTFLoaderCoordinateSystemMode {
  64744. /**
  64745. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64746. */
  64747. AUTO = 0,
  64748. /**
  64749. * Sets the useRightHandedSystem flag on the scene.
  64750. */
  64751. FORCE_RIGHT_HANDED = 1
  64752. }
  64753. /**
  64754. * Mode that determines what animations will start.
  64755. */
  64756. export enum GLTFLoaderAnimationStartMode {
  64757. /**
  64758. * No animation will start.
  64759. */
  64760. NONE = 0,
  64761. /**
  64762. * The first animation will start.
  64763. */
  64764. FIRST = 1,
  64765. /**
  64766. * All animations will start.
  64767. */
  64768. ALL = 2
  64769. }
  64770. /**
  64771. * Interface that contains the data for the glTF asset.
  64772. */
  64773. export interface IGLTFLoaderData {
  64774. /**
  64775. * Object that represents the glTF JSON.
  64776. */
  64777. json: Object;
  64778. /**
  64779. * The BIN chunk of a binary glTF.
  64780. */
  64781. bin: Nullable<ArrayBufferView>;
  64782. }
  64783. /**
  64784. * Interface for extending the loader.
  64785. */
  64786. export interface IGLTFLoaderExtension {
  64787. /**
  64788. * The name of this extension.
  64789. */
  64790. readonly name: string;
  64791. /**
  64792. * Defines whether this extension is enabled.
  64793. */
  64794. enabled: boolean;
  64795. }
  64796. /**
  64797. * Loader state.
  64798. */
  64799. export enum GLTFLoaderState {
  64800. /**
  64801. * The asset is loading.
  64802. */
  64803. LOADING = 0,
  64804. /**
  64805. * The asset is ready for rendering.
  64806. */
  64807. READY = 1,
  64808. /**
  64809. * The asset is completely loaded.
  64810. */
  64811. COMPLETE = 2
  64812. }
  64813. /** @hidden */
  64814. export interface IGLTFLoader extends IDisposable {
  64815. readonly state: Nullable<GLTFLoaderState>;
  64816. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64817. meshes: AbstractMesh[];
  64818. particleSystems: IParticleSystem[];
  64819. skeletons: Skeleton[];
  64820. animationGroups: AnimationGroup[];
  64821. }>;
  64822. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64823. }
  64824. /**
  64825. * File loader for loading glTF files into a scene.
  64826. */
  64827. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64828. /** @hidden */
  64829. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64830. /** @hidden */
  64831. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64832. /**
  64833. * Raised when the asset has been parsed
  64834. */
  64835. onParsedObservable: Observable<IGLTFLoaderData>;
  64836. private _onParsedObserver;
  64837. /**
  64838. * Raised when the asset has been parsed
  64839. */
  64840. onParsed: (loaderData: IGLTFLoaderData) => void;
  64841. /**
  64842. * 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.
  64843. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64844. * Defaults to true.
  64845. * @hidden
  64846. */
  64847. static IncrementalLoading: boolean;
  64848. /**
  64849. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64850. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64851. * @hidden
  64852. */
  64853. static HomogeneousCoordinates: boolean;
  64854. /**
  64855. * The coordinate system mode. Defaults to AUTO.
  64856. */
  64857. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64858. /**
  64859. * The animation start mode. Defaults to FIRST.
  64860. */
  64861. animationStartMode: GLTFLoaderAnimationStartMode;
  64862. /**
  64863. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64864. */
  64865. compileMaterials: boolean;
  64866. /**
  64867. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64868. */
  64869. useClipPlane: boolean;
  64870. /**
  64871. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64872. */
  64873. compileShadowGenerators: boolean;
  64874. /**
  64875. * Defines if the Alpha blended materials are only applied as coverage.
  64876. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64877. * If true, no extra effects are applied to transparent pixels.
  64878. */
  64879. transparencyAsCoverage: boolean;
  64880. /**
  64881. * Function called before loading a url referenced by the asset.
  64882. */
  64883. preprocessUrlAsync: (url: string) => Promise<string>;
  64884. /**
  64885. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64886. */
  64887. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64888. private _onMeshLoadedObserver;
  64889. /**
  64890. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64891. */
  64892. onMeshLoaded: (mesh: AbstractMesh) => void;
  64893. /**
  64894. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64895. */
  64896. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64897. private _onTextureLoadedObserver;
  64898. /**
  64899. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64900. */
  64901. onTextureLoaded: (texture: BaseTexture) => void;
  64902. /**
  64903. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64904. */
  64905. readonly onMaterialLoadedObservable: Observable<Material>;
  64906. private _onMaterialLoadedObserver;
  64907. /**
  64908. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64909. */
  64910. onMaterialLoaded: (material: Material) => void;
  64911. /**
  64912. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64913. */
  64914. readonly onCameraLoadedObservable: Observable<Camera>;
  64915. private _onCameraLoadedObserver;
  64916. /**
  64917. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64918. */
  64919. onCameraLoaded: (camera: Camera) => void;
  64920. /**
  64921. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64922. * For assets with LODs, raised when all of the LODs are complete.
  64923. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64924. */
  64925. readonly onCompleteObservable: Observable<void>;
  64926. private _onCompleteObserver;
  64927. /**
  64928. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64929. * For assets with LODs, raised when all of the LODs are complete.
  64930. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64931. */
  64932. onComplete: () => void;
  64933. /**
  64934. * Observable raised when an error occurs.
  64935. */
  64936. readonly onErrorObservable: Observable<any>;
  64937. private _onErrorObserver;
  64938. /**
  64939. * Callback raised when an error occurs.
  64940. */
  64941. onError: (reason: any) => void;
  64942. /**
  64943. * Observable raised after the loader is disposed.
  64944. */
  64945. readonly onDisposeObservable: Observable<void>;
  64946. private _onDisposeObserver;
  64947. /**
  64948. * Callback raised after the loader is disposed.
  64949. */
  64950. onDispose: () => void;
  64951. /**
  64952. * Observable raised after a loader extension is created.
  64953. * Set additional options for a loader extension in this event.
  64954. */
  64955. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64956. private _onExtensionLoadedObserver;
  64957. /**
  64958. * Callback raised after a loader extension is created.
  64959. */
  64960. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64961. /**
  64962. * Defines if the loader logging is enabled.
  64963. */
  64964. loggingEnabled: boolean;
  64965. /**
  64966. * Defines if the loader should capture performance counters.
  64967. */
  64968. capturePerformanceCounters: boolean;
  64969. /**
  64970. * Defines if the loader should validate the asset.
  64971. */
  64972. validate: boolean;
  64973. /**
  64974. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64975. */
  64976. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64977. private _onValidatedObserver;
  64978. /**
  64979. * Callback raised after a loader extension is created.
  64980. */
  64981. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64982. private _loader;
  64983. /**
  64984. * Name of the loader ("gltf")
  64985. */
  64986. name: string;
  64987. /**
  64988. * Supported file extensions of the loader (.gltf, .glb)
  64989. */
  64990. extensions: ISceneLoaderPluginExtensions;
  64991. /**
  64992. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64993. */
  64994. dispose(): void;
  64995. /** @hidden */
  64996. _clear(): void;
  64997. /**
  64998. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64999. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65000. * @param scene the scene the meshes should be added to
  65001. * @param data the glTF data to load
  65002. * @param rootUrl root url to load from
  65003. * @param onProgress event that fires when loading progress has occured
  65004. * @param fileName Defines the name of the file to load
  65005. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65006. */
  65007. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65008. meshes: AbstractMesh[];
  65009. particleSystems: IParticleSystem[];
  65010. skeletons: Skeleton[];
  65011. animationGroups: AnimationGroup[];
  65012. }>;
  65013. /**
  65014. * Imports all objects from the loaded glTF data and adds them to the scene
  65015. * @param scene the scene the objects should be added to
  65016. * @param data the glTF data to load
  65017. * @param rootUrl root url to load from
  65018. * @param onProgress event that fires when loading progress has occured
  65019. * @param fileName Defines the name of the file to load
  65020. * @returns a promise which completes when objects have been loaded to the scene
  65021. */
  65022. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65023. /**
  65024. * Load into an asset container.
  65025. * @param scene The scene to load into
  65026. * @param data The data to import
  65027. * @param rootUrl The root url for scene and resources
  65028. * @param onProgress The callback when the load progresses
  65029. * @param fileName Defines the name of the file to load
  65030. * @returns The loaded asset container
  65031. */
  65032. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65033. /**
  65034. * If the data string can be loaded directly.
  65035. * @param data string contianing the file data
  65036. * @returns if the data can be loaded directly
  65037. */
  65038. canDirectLoad(data: string): boolean;
  65039. /**
  65040. * Rewrites a url by combining a root url and response url.
  65041. */
  65042. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65043. /**
  65044. * Instantiates a glTF file loader plugin.
  65045. * @returns the created plugin
  65046. */
  65047. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65048. /**
  65049. * The loader state or null if the loader is not active.
  65050. */
  65051. readonly loaderState: Nullable<GLTFLoaderState>;
  65052. /**
  65053. * Returns a promise that resolves when the asset is completely loaded.
  65054. * @returns a promise that resolves when the asset is completely loaded.
  65055. */
  65056. whenCompleteAsync(): Promise<void>;
  65057. private _parseAsync;
  65058. private _validateAsync;
  65059. private _getLoader;
  65060. private _unpackBinary;
  65061. private _unpackBinaryV1;
  65062. private _unpackBinaryV2;
  65063. private static _parseVersion;
  65064. private static _compareVersion;
  65065. private static _decodeBufferToText;
  65066. private static readonly _logSpaces;
  65067. private _logIndentLevel;
  65068. private _loggingEnabled;
  65069. /** @hidden */
  65070. _log: (message: string) => void;
  65071. /** @hidden */
  65072. _logOpen(message: string): void;
  65073. /** @hidden */
  65074. _logClose(): void;
  65075. private _logEnabled;
  65076. private _logDisabled;
  65077. private _capturePerformanceCounters;
  65078. /** @hidden */
  65079. _startPerformanceCounter: (counterName: string) => void;
  65080. /** @hidden */
  65081. _endPerformanceCounter: (counterName: string) => void;
  65082. private _startPerformanceCounterEnabled;
  65083. private _startPerformanceCounterDisabled;
  65084. private _endPerformanceCounterEnabled;
  65085. private _endPerformanceCounterDisabled;
  65086. }
  65087. }
  65088. declare module BABYLON.GLTF1 {
  65089. /**
  65090. * Enums
  65091. * @hidden
  65092. */
  65093. export enum EComponentType {
  65094. BYTE = 5120,
  65095. UNSIGNED_BYTE = 5121,
  65096. SHORT = 5122,
  65097. UNSIGNED_SHORT = 5123,
  65098. FLOAT = 5126
  65099. }
  65100. /** @hidden */
  65101. export enum EShaderType {
  65102. FRAGMENT = 35632,
  65103. VERTEX = 35633
  65104. }
  65105. /** @hidden */
  65106. export enum EParameterType {
  65107. BYTE = 5120,
  65108. UNSIGNED_BYTE = 5121,
  65109. SHORT = 5122,
  65110. UNSIGNED_SHORT = 5123,
  65111. INT = 5124,
  65112. UNSIGNED_INT = 5125,
  65113. FLOAT = 5126,
  65114. FLOAT_VEC2 = 35664,
  65115. FLOAT_VEC3 = 35665,
  65116. FLOAT_VEC4 = 35666,
  65117. INT_VEC2 = 35667,
  65118. INT_VEC3 = 35668,
  65119. INT_VEC4 = 35669,
  65120. BOOL = 35670,
  65121. BOOL_VEC2 = 35671,
  65122. BOOL_VEC3 = 35672,
  65123. BOOL_VEC4 = 35673,
  65124. FLOAT_MAT2 = 35674,
  65125. FLOAT_MAT3 = 35675,
  65126. FLOAT_MAT4 = 35676,
  65127. SAMPLER_2D = 35678
  65128. }
  65129. /** @hidden */
  65130. export enum ETextureWrapMode {
  65131. CLAMP_TO_EDGE = 33071,
  65132. MIRRORED_REPEAT = 33648,
  65133. REPEAT = 10497
  65134. }
  65135. /** @hidden */
  65136. export enum ETextureFilterType {
  65137. NEAREST = 9728,
  65138. LINEAR = 9728,
  65139. NEAREST_MIPMAP_NEAREST = 9984,
  65140. LINEAR_MIPMAP_NEAREST = 9985,
  65141. NEAREST_MIPMAP_LINEAR = 9986,
  65142. LINEAR_MIPMAP_LINEAR = 9987
  65143. }
  65144. /** @hidden */
  65145. export enum ETextureFormat {
  65146. ALPHA = 6406,
  65147. RGB = 6407,
  65148. RGBA = 6408,
  65149. LUMINANCE = 6409,
  65150. LUMINANCE_ALPHA = 6410
  65151. }
  65152. /** @hidden */
  65153. export enum ECullingType {
  65154. FRONT = 1028,
  65155. BACK = 1029,
  65156. FRONT_AND_BACK = 1032
  65157. }
  65158. /** @hidden */
  65159. export enum EBlendingFunction {
  65160. ZERO = 0,
  65161. ONE = 1,
  65162. SRC_COLOR = 768,
  65163. ONE_MINUS_SRC_COLOR = 769,
  65164. DST_COLOR = 774,
  65165. ONE_MINUS_DST_COLOR = 775,
  65166. SRC_ALPHA = 770,
  65167. ONE_MINUS_SRC_ALPHA = 771,
  65168. DST_ALPHA = 772,
  65169. ONE_MINUS_DST_ALPHA = 773,
  65170. CONSTANT_COLOR = 32769,
  65171. ONE_MINUS_CONSTANT_COLOR = 32770,
  65172. CONSTANT_ALPHA = 32771,
  65173. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65174. SRC_ALPHA_SATURATE = 776
  65175. }
  65176. /** @hidden */
  65177. export interface IGLTFProperty {
  65178. extensions?: {
  65179. [key: string]: any;
  65180. };
  65181. extras?: Object;
  65182. }
  65183. /** @hidden */
  65184. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65185. name?: string;
  65186. }
  65187. /** @hidden */
  65188. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65189. bufferView: string;
  65190. byteOffset: number;
  65191. byteStride: number;
  65192. count: number;
  65193. type: string;
  65194. componentType: EComponentType;
  65195. max?: number[];
  65196. min?: number[];
  65197. name?: string;
  65198. }
  65199. /** @hidden */
  65200. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65201. buffer: string;
  65202. byteOffset: number;
  65203. byteLength: number;
  65204. byteStride: number;
  65205. target?: number;
  65206. }
  65207. /** @hidden */
  65208. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65209. uri: string;
  65210. byteLength?: number;
  65211. type?: string;
  65212. }
  65213. /** @hidden */
  65214. export interface IGLTFShader extends IGLTFChildRootProperty {
  65215. uri: string;
  65216. type: EShaderType;
  65217. }
  65218. /** @hidden */
  65219. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65220. attributes: string[];
  65221. fragmentShader: string;
  65222. vertexShader: string;
  65223. }
  65224. /** @hidden */
  65225. export interface IGLTFTechniqueParameter {
  65226. type: number;
  65227. count?: number;
  65228. semantic?: string;
  65229. node?: string;
  65230. value?: number | boolean | string | Array<any>;
  65231. source?: string;
  65232. babylonValue?: any;
  65233. }
  65234. /** @hidden */
  65235. export interface IGLTFTechniqueCommonProfile {
  65236. lightingModel: string;
  65237. texcoordBindings: Object;
  65238. parameters?: Array<any>;
  65239. }
  65240. /** @hidden */
  65241. export interface IGLTFTechniqueStatesFunctions {
  65242. blendColor?: number[];
  65243. blendEquationSeparate?: number[];
  65244. blendFuncSeparate?: number[];
  65245. colorMask: boolean[];
  65246. cullFace: number[];
  65247. }
  65248. /** @hidden */
  65249. export interface IGLTFTechniqueStates {
  65250. enable: number[];
  65251. functions: IGLTFTechniqueStatesFunctions;
  65252. }
  65253. /** @hidden */
  65254. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65255. parameters: {
  65256. [key: string]: IGLTFTechniqueParameter;
  65257. };
  65258. program: string;
  65259. attributes: {
  65260. [key: string]: string;
  65261. };
  65262. uniforms: {
  65263. [key: string]: string;
  65264. };
  65265. states: IGLTFTechniqueStates;
  65266. }
  65267. /** @hidden */
  65268. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65269. technique?: string;
  65270. values: string[];
  65271. }
  65272. /** @hidden */
  65273. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65274. attributes: {
  65275. [key: string]: string;
  65276. };
  65277. indices: string;
  65278. material: string;
  65279. mode?: number;
  65280. }
  65281. /** @hidden */
  65282. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65283. primitives: IGLTFMeshPrimitive[];
  65284. }
  65285. /** @hidden */
  65286. export interface IGLTFImage extends IGLTFChildRootProperty {
  65287. uri: string;
  65288. }
  65289. /** @hidden */
  65290. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65291. magFilter?: number;
  65292. minFilter?: number;
  65293. wrapS?: number;
  65294. wrapT?: number;
  65295. }
  65296. /** @hidden */
  65297. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65298. sampler: string;
  65299. source: string;
  65300. format?: ETextureFormat;
  65301. internalFormat?: ETextureFormat;
  65302. target?: number;
  65303. type?: number;
  65304. babylonTexture?: Texture;
  65305. }
  65306. /** @hidden */
  65307. export interface IGLTFAmbienLight {
  65308. color?: number[];
  65309. }
  65310. /** @hidden */
  65311. export interface IGLTFDirectionalLight {
  65312. color?: number[];
  65313. }
  65314. /** @hidden */
  65315. export interface IGLTFPointLight {
  65316. color?: number[];
  65317. constantAttenuation?: number;
  65318. linearAttenuation?: number;
  65319. quadraticAttenuation?: number;
  65320. }
  65321. /** @hidden */
  65322. export interface IGLTFSpotLight {
  65323. color?: number[];
  65324. constantAttenuation?: number;
  65325. fallOfAngle?: number;
  65326. fallOffExponent?: number;
  65327. linearAttenuation?: number;
  65328. quadraticAttenuation?: number;
  65329. }
  65330. /** @hidden */
  65331. export interface IGLTFLight extends IGLTFChildRootProperty {
  65332. type: string;
  65333. }
  65334. /** @hidden */
  65335. export interface IGLTFCameraOrthographic {
  65336. xmag: number;
  65337. ymag: number;
  65338. zfar: number;
  65339. znear: number;
  65340. }
  65341. /** @hidden */
  65342. export interface IGLTFCameraPerspective {
  65343. aspectRatio: number;
  65344. yfov: number;
  65345. zfar: number;
  65346. znear: number;
  65347. }
  65348. /** @hidden */
  65349. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65350. type: string;
  65351. }
  65352. /** @hidden */
  65353. export interface IGLTFAnimationChannelTarget {
  65354. id: string;
  65355. path: string;
  65356. }
  65357. /** @hidden */
  65358. export interface IGLTFAnimationChannel {
  65359. sampler: string;
  65360. target: IGLTFAnimationChannelTarget;
  65361. }
  65362. /** @hidden */
  65363. export interface IGLTFAnimationSampler {
  65364. input: string;
  65365. output: string;
  65366. interpolation?: string;
  65367. }
  65368. /** @hidden */
  65369. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65370. channels?: IGLTFAnimationChannel[];
  65371. parameters?: {
  65372. [key: string]: string;
  65373. };
  65374. samplers?: {
  65375. [key: string]: IGLTFAnimationSampler;
  65376. };
  65377. }
  65378. /** @hidden */
  65379. export interface IGLTFNodeInstanceSkin {
  65380. skeletons: string[];
  65381. skin: string;
  65382. meshes: string[];
  65383. }
  65384. /** @hidden */
  65385. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65386. bindShapeMatrix: number[];
  65387. inverseBindMatrices: string;
  65388. jointNames: string[];
  65389. babylonSkeleton?: Skeleton;
  65390. }
  65391. /** @hidden */
  65392. export interface IGLTFNode extends IGLTFChildRootProperty {
  65393. camera?: string;
  65394. children: string[];
  65395. skin?: string;
  65396. jointName?: string;
  65397. light?: string;
  65398. matrix: number[];
  65399. mesh?: string;
  65400. meshes?: string[];
  65401. rotation?: number[];
  65402. scale?: number[];
  65403. translation?: number[];
  65404. babylonNode?: Node;
  65405. }
  65406. /** @hidden */
  65407. export interface IGLTFScene extends IGLTFChildRootProperty {
  65408. nodes: string[];
  65409. }
  65410. /** @hidden */
  65411. export interface IGLTFRuntime {
  65412. extensions: {
  65413. [key: string]: any;
  65414. };
  65415. accessors: {
  65416. [key: string]: IGLTFAccessor;
  65417. };
  65418. buffers: {
  65419. [key: string]: IGLTFBuffer;
  65420. };
  65421. bufferViews: {
  65422. [key: string]: IGLTFBufferView;
  65423. };
  65424. meshes: {
  65425. [key: string]: IGLTFMesh;
  65426. };
  65427. lights: {
  65428. [key: string]: IGLTFLight;
  65429. };
  65430. cameras: {
  65431. [key: string]: IGLTFCamera;
  65432. };
  65433. nodes: {
  65434. [key: string]: IGLTFNode;
  65435. };
  65436. images: {
  65437. [key: string]: IGLTFImage;
  65438. };
  65439. textures: {
  65440. [key: string]: IGLTFTexture;
  65441. };
  65442. shaders: {
  65443. [key: string]: IGLTFShader;
  65444. };
  65445. programs: {
  65446. [key: string]: IGLTFProgram;
  65447. };
  65448. samplers: {
  65449. [key: string]: IGLTFSampler;
  65450. };
  65451. techniques: {
  65452. [key: string]: IGLTFTechnique;
  65453. };
  65454. materials: {
  65455. [key: string]: IGLTFMaterial;
  65456. };
  65457. animations: {
  65458. [key: string]: IGLTFAnimation;
  65459. };
  65460. skins: {
  65461. [key: string]: IGLTFSkins;
  65462. };
  65463. currentScene?: Object;
  65464. scenes: {
  65465. [key: string]: IGLTFScene;
  65466. };
  65467. extensionsUsed: string[];
  65468. extensionsRequired?: string[];
  65469. buffersCount: number;
  65470. shaderscount: number;
  65471. scene: Scene;
  65472. rootUrl: string;
  65473. loadedBufferCount: number;
  65474. loadedBufferViews: {
  65475. [name: string]: ArrayBufferView;
  65476. };
  65477. loadedShaderCount: number;
  65478. importOnlyMeshes: boolean;
  65479. importMeshesNames?: string[];
  65480. dummyNodes: Node[];
  65481. }
  65482. /** @hidden */
  65483. export interface INodeToRoot {
  65484. bone: Bone;
  65485. node: IGLTFNode;
  65486. id: string;
  65487. }
  65488. /** @hidden */
  65489. export interface IJointNode {
  65490. node: IGLTFNode;
  65491. id: string;
  65492. }
  65493. }
  65494. declare module BABYLON.GLTF1 {
  65495. /**
  65496. * Utils functions for GLTF
  65497. * @hidden
  65498. */
  65499. export class GLTFUtils {
  65500. /**
  65501. * Sets the given "parameter" matrix
  65502. * @param scene: the Scene object
  65503. * @param source: the source node where to pick the matrix
  65504. * @param parameter: the GLTF technique parameter
  65505. * @param uniformName: the name of the shader's uniform
  65506. * @param shaderMaterial: the shader material
  65507. */
  65508. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65509. /**
  65510. * Sets the given "parameter" matrix
  65511. * @param shaderMaterial: the shader material
  65512. * @param uniform: the name of the shader's uniform
  65513. * @param value: the value of the uniform
  65514. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65515. */
  65516. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65517. /**
  65518. * Returns the wrap mode of the texture
  65519. * @param mode: the mode value
  65520. */
  65521. static GetWrapMode(mode: number): number;
  65522. /**
  65523. * Returns the byte stride giving an accessor
  65524. * @param accessor: the GLTF accessor objet
  65525. */
  65526. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65527. /**
  65528. * Returns the texture filter mode giving a mode value
  65529. * @param mode: the filter mode value
  65530. */
  65531. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65532. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65533. /**
  65534. * Returns a buffer from its accessor
  65535. * @param gltfRuntime: the GLTF runtime
  65536. * @param accessor: the GLTF accessor
  65537. */
  65538. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65539. /**
  65540. * Decodes a buffer view into a string
  65541. * @param view: the buffer view
  65542. */
  65543. static DecodeBufferToText(view: ArrayBufferView): string;
  65544. /**
  65545. * Returns the default material of gltf. Related to
  65546. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65547. * @param scene: the Babylon.js scene
  65548. */
  65549. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65550. private static _DefaultMaterial;
  65551. }
  65552. }
  65553. declare module BABYLON.GLTF1 {
  65554. /**
  65555. * Implementation of the base glTF spec
  65556. * @hidden
  65557. */
  65558. export class GLTFLoaderBase {
  65559. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65560. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65561. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65562. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65563. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65564. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65565. }
  65566. /**
  65567. * glTF V1 Loader
  65568. * @hidden
  65569. */
  65570. export class GLTFLoader implements IGLTFLoader {
  65571. static Extensions: {
  65572. [name: string]: GLTFLoaderExtension;
  65573. };
  65574. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65575. state: Nullable<GLTFLoaderState>;
  65576. dispose(): void;
  65577. private _importMeshAsync;
  65578. /**
  65579. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65580. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65581. * @param scene the scene the meshes should be added to
  65582. * @param data gltf data containing information of the meshes in a loaded file
  65583. * @param rootUrl root url to load from
  65584. * @param onProgress event that fires when loading progress has occured
  65585. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65586. */
  65587. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65588. meshes: AbstractMesh[];
  65589. particleSystems: IParticleSystem[];
  65590. skeletons: Skeleton[];
  65591. animationGroups: AnimationGroup[];
  65592. }>;
  65593. private _loadAsync;
  65594. /**
  65595. * Imports all objects from a loaded gltf file and adds them to the scene
  65596. * @param scene the scene the objects should be added to
  65597. * @param data gltf data containing information of the meshes in a loaded file
  65598. * @param rootUrl root url to load from
  65599. * @param onProgress event that fires when loading progress has occured
  65600. * @returns a promise which completes when objects have been loaded to the scene
  65601. */
  65602. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65603. private _loadShadersAsync;
  65604. private _loadBuffersAsync;
  65605. private _createNodes;
  65606. }
  65607. /** @hidden */
  65608. export abstract class GLTFLoaderExtension {
  65609. private _name;
  65610. constructor(name: string);
  65611. readonly name: string;
  65612. /**
  65613. * Defines an override for loading the runtime
  65614. * Return true to stop further extensions from loading the runtime
  65615. */
  65616. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65617. /**
  65618. * Defines an onverride for creating gltf runtime
  65619. * Return true to stop further extensions from creating the runtime
  65620. */
  65621. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65622. /**
  65623. * Defines an override for loading buffers
  65624. * Return true to stop further extensions from loading this buffer
  65625. */
  65626. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65627. /**
  65628. * Defines an override for loading texture buffers
  65629. * Return true to stop further extensions from loading this texture data
  65630. */
  65631. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65632. /**
  65633. * Defines an override for creating textures
  65634. * Return true to stop further extensions from loading this texture
  65635. */
  65636. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65637. /**
  65638. * Defines an override for loading shader strings
  65639. * Return true to stop further extensions from loading this shader data
  65640. */
  65641. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65642. /**
  65643. * Defines an override for loading materials
  65644. * Return true to stop further extensions from loading this material
  65645. */
  65646. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65647. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65648. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65649. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65650. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65651. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65652. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65653. private static LoadTextureBufferAsync;
  65654. private static CreateTextureAsync;
  65655. private static ApplyExtensions;
  65656. }
  65657. }
  65658. declare module BABYLON.GLTF1 {
  65659. /** @hidden */
  65660. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65661. private _bin;
  65662. constructor();
  65663. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65664. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65665. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65666. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65667. }
  65668. }
  65669. declare module BABYLON.GLTF1 {
  65670. /** @hidden */
  65671. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65672. constructor();
  65673. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65674. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65675. private _loadTexture;
  65676. }
  65677. }
  65678. declare module BABYLON.GLTF2.Loader {
  65679. /**
  65680. * Loader interface with an index field.
  65681. */
  65682. export interface IArrayItem {
  65683. /**
  65684. * The index of this item in the array.
  65685. */
  65686. index: number;
  65687. }
  65688. /**
  65689. * Loader interface with additional members.
  65690. */
  65691. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65692. /** @hidden */
  65693. _data?: Promise<ArrayBufferView>;
  65694. /** @hidden */
  65695. _babylonVertexBuffer?: Promise<VertexBuffer>;
  65696. }
  65697. /**
  65698. * Loader interface with additional members.
  65699. */
  65700. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  65701. }
  65702. /** @hidden */
  65703. export interface _IAnimationSamplerData {
  65704. input: Float32Array;
  65705. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  65706. output: Float32Array;
  65707. }
  65708. /**
  65709. * Loader interface with additional members.
  65710. */
  65711. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  65712. /** @hidden */
  65713. _data?: Promise<_IAnimationSamplerData>;
  65714. }
  65715. /**
  65716. * Loader interface with additional members.
  65717. */
  65718. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  65719. channels: IAnimationChannel[];
  65720. samplers: IAnimationSampler[];
  65721. /** @hidden */
  65722. _babylonAnimationGroup?: AnimationGroup;
  65723. }
  65724. /**
  65725. * Loader interface with additional members.
  65726. */
  65727. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  65728. /** @hidden */
  65729. _data?: Promise<ArrayBufferView>;
  65730. }
  65731. /**
  65732. * Loader interface with additional members.
  65733. */
  65734. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  65735. /** @hidden */
  65736. _data?: Promise<ArrayBufferView>;
  65737. /** @hidden */
  65738. _babylonBuffer?: Promise<Buffer>;
  65739. }
  65740. /**
  65741. * Loader interface with additional members.
  65742. */
  65743. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65744. }
  65745. /**
  65746. * Loader interface with additional members.
  65747. */
  65748. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65749. /** @hidden */
  65750. _data?: Promise<ArrayBufferView>;
  65751. }
  65752. /**
  65753. * Loader interface with additional members.
  65754. */
  65755. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65756. }
  65757. /**
  65758. * Loader interface with additional members.
  65759. */
  65760. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65761. }
  65762. /**
  65763. * Loader interface with additional members.
  65764. */
  65765. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65766. baseColorTexture?: ITextureInfo;
  65767. metallicRoughnessTexture?: ITextureInfo;
  65768. }
  65769. /**
  65770. * Loader interface with additional members.
  65771. */
  65772. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65773. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65774. normalTexture?: IMaterialNormalTextureInfo;
  65775. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65776. emissiveTexture?: ITextureInfo;
  65777. /** @hidden */
  65778. _data?: {
  65779. [babylonDrawMode: number]: {
  65780. babylonMaterial: Material;
  65781. babylonMeshes: AbstractMesh[];
  65782. promise: Promise<void>;
  65783. };
  65784. };
  65785. }
  65786. /**
  65787. * Loader interface with additional members.
  65788. */
  65789. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65790. primitives: IMeshPrimitive[];
  65791. }
  65792. /**
  65793. * Loader interface with additional members.
  65794. */
  65795. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65796. /** @hidden */
  65797. _instanceData?: {
  65798. babylonSourceMesh: Mesh;
  65799. promise: Promise<any>;
  65800. };
  65801. }
  65802. /**
  65803. * Loader interface with additional members.
  65804. */
  65805. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65806. /**
  65807. * The parent glTF node.
  65808. */
  65809. parent?: INode;
  65810. /** @hidden */
  65811. _babylonTransformNode?: TransformNode;
  65812. /** @hidden */
  65813. _primitiveBabylonMeshes?: AbstractMesh[];
  65814. /** @hidden */
  65815. _babylonBones?: Bone[];
  65816. /** @hidden */
  65817. _numMorphTargets?: number;
  65818. }
  65819. /** @hidden */
  65820. export interface _ISamplerData {
  65821. noMipMaps: boolean;
  65822. samplingMode: number;
  65823. wrapU: number;
  65824. wrapV: number;
  65825. }
  65826. /**
  65827. * Loader interface with additional members.
  65828. */
  65829. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65830. /** @hidden */
  65831. _data?: _ISamplerData;
  65832. }
  65833. /**
  65834. * Loader interface with additional members.
  65835. */
  65836. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65837. }
  65838. /**
  65839. * Loader interface with additional members.
  65840. */
  65841. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65842. /** @hidden */
  65843. _data?: {
  65844. babylonSkeleton: Skeleton;
  65845. promise: Promise<void>;
  65846. };
  65847. }
  65848. /**
  65849. * Loader interface with additional members.
  65850. */
  65851. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65852. }
  65853. /**
  65854. * Loader interface with additional members.
  65855. */
  65856. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65857. }
  65858. /**
  65859. * Loader interface with additional members.
  65860. */
  65861. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65862. accessors?: IAccessor[];
  65863. animations?: IAnimation[];
  65864. buffers?: IBuffer[];
  65865. bufferViews?: IBufferView[];
  65866. cameras?: ICamera[];
  65867. images?: IImage[];
  65868. materials?: IMaterial[];
  65869. meshes?: IMesh[];
  65870. nodes?: INode[];
  65871. samplers?: ISampler[];
  65872. scenes?: IScene[];
  65873. skins?: ISkin[];
  65874. textures?: ITexture[];
  65875. }
  65876. }
  65877. declare module BABYLON.GLTF2 {
  65878. /**
  65879. * Interface for a glTF loader extension.
  65880. */
  65881. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65882. /**
  65883. * Called after the loader state changes to LOADING.
  65884. */
  65885. onLoading?(): void;
  65886. /**
  65887. * Called after the loader state changes to READY.
  65888. */
  65889. onReady?(): void;
  65890. /**
  65891. * Define this method to modify the default behavior when loading scenes.
  65892. * @param context The context when loading the asset
  65893. * @param scene The glTF scene property
  65894. * @returns A promise that resolves when the load is complete or null if not handled
  65895. */
  65896. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65897. /**
  65898. * Define this method to modify the default behavior when loading nodes.
  65899. * @param context The context when loading the asset
  65900. * @param node The glTF node property
  65901. * @param assign A function called synchronously after parsing the glTF properties
  65902. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65903. */
  65904. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65905. /**
  65906. * Define this method to modify the default behavior when loading cameras.
  65907. * @param context The context when loading the asset
  65908. * @param camera The glTF camera property
  65909. * @param assign A function called synchronously after parsing the glTF properties
  65910. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65911. */
  65912. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65913. /**
  65914. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65915. * @param context The context when loading the asset
  65916. * @param primitive The glTF mesh primitive property
  65917. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65918. */
  65919. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65920. /**
  65921. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65922. * @param context The context when loading the asset
  65923. * @param name The mesh name when loading the asset
  65924. * @param node The glTF node when loading the asset
  65925. * @param mesh The glTF mesh when loading the asset
  65926. * @param primitive The glTF mesh primitive property
  65927. * @param assign A function called synchronously after parsing the glTF properties
  65928. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65929. */
  65930. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65931. /**
  65932. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65933. * @param context The context when loading the asset
  65934. * @param material The glTF material property
  65935. * @param assign A function called synchronously after parsing the glTF properties
  65936. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65937. */
  65938. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65939. /**
  65940. * Define this method to modify the default behavior when creating materials.
  65941. * @param context The context when loading the asset
  65942. * @param material The glTF material property
  65943. * @param babylonDrawMode The draw mode for the Babylon material
  65944. * @returns The Babylon material or null if not handled
  65945. */
  65946. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65947. /**
  65948. * Define this method to modify the default behavior when loading material properties.
  65949. * @param context The context when loading the asset
  65950. * @param material The glTF material property
  65951. * @param babylonMaterial The Babylon material
  65952. * @returns A promise that resolves when the load is complete or null if not handled
  65953. */
  65954. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65955. /**
  65956. * Define this method to modify the default behavior when loading texture infos.
  65957. * @param context The context when loading the asset
  65958. * @param textureInfo The glTF texture info property
  65959. * @param assign A function called synchronously after parsing the glTF properties
  65960. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65961. */
  65962. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65963. /**
  65964. * Define this method to modify the default behavior when loading animations.
  65965. * @param context The context when loading the asset
  65966. * @param animation The glTF animation property
  65967. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65968. */
  65969. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65970. /**
  65971. * @hidden Define this method to modify the default behavior when loading skins.
  65972. * @param context The context when loading the asset
  65973. * @param node The glTF node property
  65974. * @param skin The glTF skin property
  65975. * @returns A promise that resolves when the load is complete or null if not handled
  65976. */
  65977. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65978. /**
  65979. * @hidden Define this method to modify the default behavior when loading uris.
  65980. * @param context The context when loading the asset
  65981. * @param property The glTF property associated with the uri
  65982. * @param uri The uri to load
  65983. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65984. */
  65985. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65986. }
  65987. }
  65988. declare module BABYLON.GLTF2 {
  65989. /**
  65990. * Helper class for working with arrays when loading the glTF asset
  65991. */
  65992. export class ArrayItem {
  65993. /**
  65994. * Gets an item from the given array.
  65995. * @param context The context when loading the asset
  65996. * @param array The array to get the item from
  65997. * @param index The index to the array
  65998. * @returns The array item
  65999. */
  66000. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66001. /**
  66002. * Assign an `index` field to each item of the given array.
  66003. * @param array The array of items
  66004. */
  66005. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66006. }
  66007. /**
  66008. * The glTF 2.0 loader
  66009. */
  66010. export class GLTFLoader implements IGLTFLoader {
  66011. /** @hidden */
  66012. _completePromises: Promise<any>[];
  66013. private _disposed;
  66014. private _parent;
  66015. private _state;
  66016. private _extensions;
  66017. private _rootUrl;
  66018. private _fileName;
  66019. private _uniqueRootUrl;
  66020. private _gltf;
  66021. private _babylonScene;
  66022. private _rootBabylonMesh;
  66023. private _defaultBabylonMaterialData;
  66024. private _progressCallback?;
  66025. private _requests;
  66026. private static readonly _DefaultSampler;
  66027. private static _ExtensionNames;
  66028. private static _ExtensionFactories;
  66029. /**
  66030. * Registers a loader extension.
  66031. * @param name The name of the loader extension.
  66032. * @param factory The factory function that creates the loader extension.
  66033. */
  66034. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66035. /**
  66036. * Unregisters a loader extension.
  66037. * @param name The name of the loader extenion.
  66038. * @returns A boolean indicating whether the extension has been unregistered
  66039. */
  66040. static UnregisterExtension(name: string): boolean;
  66041. /**
  66042. * Gets the loader state.
  66043. */
  66044. readonly state: Nullable<GLTFLoaderState>;
  66045. /**
  66046. * The glTF object parsed from the JSON.
  66047. */
  66048. readonly gltf: IGLTF;
  66049. /**
  66050. * The Babylon scene when loading the asset.
  66051. */
  66052. readonly babylonScene: Scene;
  66053. /**
  66054. * The root Babylon mesh when loading the asset.
  66055. */
  66056. readonly rootBabylonMesh: Mesh;
  66057. /** @hidden */
  66058. constructor(parent: GLTFFileLoader);
  66059. /** @hidden */
  66060. dispose(): void;
  66061. /** @hidden */
  66062. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66063. meshes: AbstractMesh[];
  66064. particleSystems: IParticleSystem[];
  66065. skeletons: Skeleton[];
  66066. animationGroups: AnimationGroup[];
  66067. }>;
  66068. /** @hidden */
  66069. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66070. private _loadAsync;
  66071. private _loadData;
  66072. private _setupData;
  66073. private _loadExtensions;
  66074. private _checkExtensions;
  66075. private _setState;
  66076. private _createRootNode;
  66077. /**
  66078. * Loads a glTF scene.
  66079. * @param context The context when loading the asset
  66080. * @param scene The glTF scene property
  66081. * @returns A promise that resolves when the load is complete
  66082. */
  66083. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66084. private _forEachPrimitive;
  66085. private _getMeshes;
  66086. private _getSkeletons;
  66087. private _getAnimationGroups;
  66088. private _startAnimations;
  66089. /**
  66090. * Loads a glTF node.
  66091. * @param context The context when loading the asset
  66092. * @param node The glTF node property
  66093. * @param assign A function called synchronously after parsing the glTF properties
  66094. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66095. */
  66096. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66097. private _loadMeshAsync;
  66098. /**
  66099. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66100. * @param context The context when loading the asset
  66101. * @param name The mesh name when loading the asset
  66102. * @param node The glTF node when loading the asset
  66103. * @param mesh The glTF mesh when loading the asset
  66104. * @param primitive The glTF mesh primitive property
  66105. * @param assign A function called synchronously after parsing the glTF properties
  66106. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66107. */
  66108. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66109. private _loadVertexDataAsync;
  66110. private _createMorphTargets;
  66111. private _loadMorphTargetsAsync;
  66112. private _loadMorphTargetVertexDataAsync;
  66113. private static _LoadTransform;
  66114. private _loadSkinAsync;
  66115. private _loadBones;
  66116. private _loadBone;
  66117. private _loadSkinInverseBindMatricesDataAsync;
  66118. private _updateBoneMatrices;
  66119. private _getNodeMatrix;
  66120. /**
  66121. * Loads a glTF camera.
  66122. * @param context The context when loading the asset
  66123. * @param camera The glTF camera property
  66124. * @param assign A function called synchronously after parsing the glTF properties
  66125. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66126. */
  66127. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66128. private _loadAnimationsAsync;
  66129. /**
  66130. * Loads a glTF animation.
  66131. * @param context The context when loading the asset
  66132. * @param animation The glTF animation property
  66133. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66134. */
  66135. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66136. /**
  66137. * @hidden Loads a glTF animation channel.
  66138. * @param context The context when loading the asset
  66139. * @param animationContext The context of the animation when loading the asset
  66140. * @param animation The glTF animation property
  66141. * @param channel The glTF animation channel property
  66142. * @param babylonAnimationGroup The babylon animation group property
  66143. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66144. * @returns A void promise when the channel load is complete
  66145. */
  66146. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66147. private _loadAnimationSamplerAsync;
  66148. private _loadBufferAsync;
  66149. /**
  66150. * Loads a glTF buffer view.
  66151. * @param context The context when loading the asset
  66152. * @param bufferView The glTF buffer view property
  66153. * @returns A promise that resolves with the loaded data when the load is complete
  66154. */
  66155. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66156. private _loadAccessorAsync;
  66157. private _loadFloatAccessorAsync;
  66158. private _loadIndicesAccessorAsync;
  66159. private _loadVertexBufferViewAsync;
  66160. private _loadVertexAccessorAsync;
  66161. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66162. /** @hidden */
  66163. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66164. private _createDefaultMaterial;
  66165. /**
  66166. * Creates a Babylon material from a glTF material.
  66167. * @param context The context when loading the asset
  66168. * @param material The glTF material property
  66169. * @param babylonDrawMode The draw mode for the Babylon material
  66170. * @returns The Babylon material
  66171. */
  66172. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66173. /**
  66174. * Loads properties from a glTF material into a Babylon material.
  66175. * @param context The context when loading the asset
  66176. * @param material The glTF material property
  66177. * @param babylonMaterial The Babylon material
  66178. * @returns A promise that resolves when the load is complete
  66179. */
  66180. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66181. /**
  66182. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66183. * @param context The context when loading the asset
  66184. * @param material The glTF material property
  66185. * @param babylonMaterial The Babylon material
  66186. * @returns A promise that resolves when the load is complete
  66187. */
  66188. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66189. /**
  66190. * Loads the alpha properties from a glTF material into a Babylon material.
  66191. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66192. * @param context The context when loading the asset
  66193. * @param material The glTF material property
  66194. * @param babylonMaterial The Babylon material
  66195. */
  66196. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66197. /**
  66198. * Loads a glTF texture info.
  66199. * @param context The context when loading the asset
  66200. * @param textureInfo The glTF texture info property
  66201. * @param assign A function called synchronously after parsing the glTF properties
  66202. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66203. */
  66204. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66205. private _loadTextureAsync;
  66206. private _loadSampler;
  66207. /**
  66208. * Loads a glTF image.
  66209. * @param context The context when loading the asset
  66210. * @param image The glTF image property
  66211. * @returns A promise that resolves with the loaded data when the load is complete
  66212. */
  66213. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66214. /**
  66215. * Loads a glTF uri.
  66216. * @param context The context when loading the asset
  66217. * @param property The glTF property associated with the uri
  66218. * @param uri The base64 or relative uri
  66219. * @returns A promise that resolves with the loaded data when the load is complete
  66220. */
  66221. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66222. private _onProgress;
  66223. /**
  66224. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66225. * @param babylonObject the Babylon object with metadata
  66226. * @param pointer the JSON pointer
  66227. */
  66228. static AddPointerMetadata(babylonObject: {
  66229. metadata: any;
  66230. }, pointer: string): void;
  66231. private static _GetTextureWrapMode;
  66232. private static _GetTextureSamplingMode;
  66233. private static _GetTypedArrayConstructor;
  66234. private static _GetTypedArray;
  66235. private static _GetNumComponents;
  66236. private static _ValidateUri;
  66237. private static _GetDrawMode;
  66238. private _compileMaterialsAsync;
  66239. private _compileShadowGeneratorsAsync;
  66240. private _forEachExtensions;
  66241. private _applyExtensions;
  66242. private _extensionsOnLoading;
  66243. private _extensionsOnReady;
  66244. private _extensionsLoadSceneAsync;
  66245. private _extensionsLoadNodeAsync;
  66246. private _extensionsLoadCameraAsync;
  66247. private _extensionsLoadVertexDataAsync;
  66248. private _extensionsLoadMeshPrimitiveAsync;
  66249. private _extensionsLoadMaterialAsync;
  66250. private _extensionsCreateMaterial;
  66251. private _extensionsLoadMaterialPropertiesAsync;
  66252. private _extensionsLoadTextureInfoAsync;
  66253. private _extensionsLoadAnimationAsync;
  66254. private _extensionsLoadSkinAsync;
  66255. private _extensionsLoadUriAsync;
  66256. /**
  66257. * Helper method called by a loader extension to load an glTF extension.
  66258. * @param context The context when loading the asset
  66259. * @param property The glTF property to load the extension from
  66260. * @param extensionName The name of the extension to load
  66261. * @param actionAsync The action to run
  66262. * @returns The promise returned by actionAsync or null if the extension does not exist
  66263. */
  66264. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66265. /**
  66266. * Helper method called by a loader extension to load a glTF extra.
  66267. * @param context The context when loading the asset
  66268. * @param property The glTF property to load the extra from
  66269. * @param extensionName The name of the extension to load
  66270. * @param actionAsync The action to run
  66271. * @returns The promise returned by actionAsync or null if the extra does not exist
  66272. */
  66273. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66274. /**
  66275. * Increments the indentation level and logs a message.
  66276. * @param message The message to log
  66277. */
  66278. logOpen(message: string): void;
  66279. /**
  66280. * Decrements the indentation level.
  66281. */
  66282. logClose(): void;
  66283. /**
  66284. * Logs a message
  66285. * @param message The message to log
  66286. */
  66287. log(message: string): void;
  66288. /**
  66289. * Starts a performance counter.
  66290. * @param counterName The name of the performance counter
  66291. */
  66292. startPerformanceCounter(counterName: string): void;
  66293. /**
  66294. * Ends a performance counter.
  66295. * @param counterName The name of the performance counter
  66296. */
  66297. endPerformanceCounter(counterName: string): void;
  66298. }
  66299. }
  66300. declare module BABYLON.GLTF2.Loader.Extensions {
  66301. /**
  66302. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66303. */
  66304. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66305. /** The name of this extension. */
  66306. readonly name: string;
  66307. /** Defines whether this extension is enabled. */
  66308. enabled: boolean;
  66309. private _loader;
  66310. private _lights?;
  66311. /** @hidden */
  66312. constructor(loader: GLTFLoader);
  66313. /** @hidden */
  66314. dispose(): void;
  66315. /** @hidden */
  66316. onLoading(): void;
  66317. /** @hidden */
  66318. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66319. private _loadLightAsync;
  66320. }
  66321. }
  66322. declare module BABYLON.GLTF2.Loader.Extensions {
  66323. /**
  66324. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66325. */
  66326. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66327. /** The name of this extension. */
  66328. readonly name: string;
  66329. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66330. dracoCompression?: DracoCompression;
  66331. /** Defines whether this extension is enabled. */
  66332. enabled: boolean;
  66333. private _loader;
  66334. /** @hidden */
  66335. constructor(loader: GLTFLoader);
  66336. /** @hidden */
  66337. dispose(): void;
  66338. /** @hidden */
  66339. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66340. }
  66341. }
  66342. declare module BABYLON.GLTF2.Loader.Extensions {
  66343. /**
  66344. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66345. */
  66346. export class KHR_lights implements IGLTFLoaderExtension {
  66347. /** The name of this extension. */
  66348. readonly name: string;
  66349. /** Defines whether this extension is enabled. */
  66350. enabled: boolean;
  66351. private _loader;
  66352. private _lights?;
  66353. /** @hidden */
  66354. constructor(loader: GLTFLoader);
  66355. /** @hidden */
  66356. dispose(): void;
  66357. /** @hidden */
  66358. onLoading(): void;
  66359. /** @hidden */
  66360. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66361. }
  66362. }
  66363. declare module BABYLON.GLTF2.Loader.Extensions {
  66364. /**
  66365. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66366. */
  66367. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66368. /** The name of this extension. */
  66369. readonly name: string;
  66370. /** Defines whether this extension is enabled. */
  66371. enabled: boolean;
  66372. private _loader;
  66373. /** @hidden */
  66374. constructor(loader: GLTFLoader);
  66375. /** @hidden */
  66376. dispose(): void;
  66377. /** @hidden */
  66378. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66379. private _loadSpecularGlossinessPropertiesAsync;
  66380. }
  66381. }
  66382. declare module BABYLON.GLTF2.Loader.Extensions {
  66383. /**
  66384. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66385. */
  66386. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66387. /** The name of this extension. */
  66388. readonly name: string;
  66389. /** Defines whether this extension is enabled. */
  66390. enabled: boolean;
  66391. private _loader;
  66392. /** @hidden */
  66393. constructor(loader: GLTFLoader);
  66394. /** @hidden */
  66395. dispose(): void;
  66396. /** @hidden */
  66397. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66398. private _loadUnlitPropertiesAsync;
  66399. }
  66400. }
  66401. declare module BABYLON.GLTF2.Loader.Extensions {
  66402. /**
  66403. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66404. */
  66405. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66406. /** The name of this extension. */
  66407. readonly name: string;
  66408. /** Defines whether this extension is enabled. */
  66409. enabled: boolean;
  66410. private _loader;
  66411. /** @hidden */
  66412. constructor(loader: GLTFLoader);
  66413. /** @hidden */
  66414. dispose(): void;
  66415. /** @hidden */
  66416. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66417. }
  66418. }
  66419. declare module BABYLON.GLTF2.Loader.Extensions {
  66420. /**
  66421. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66422. */
  66423. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66424. /** The name of this extension. */
  66425. readonly name: string;
  66426. /** Defines whether this extension is enabled. */
  66427. enabled: boolean;
  66428. private _loader;
  66429. private _clips;
  66430. private _emitters;
  66431. /** @hidden */
  66432. constructor(loader: GLTFLoader);
  66433. /** @hidden */
  66434. dispose(): void;
  66435. /** @hidden */
  66436. onLoading(): void;
  66437. /** @hidden */
  66438. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66439. /** @hidden */
  66440. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66441. /** @hidden */
  66442. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66443. private _loadClipAsync;
  66444. private _loadEmitterAsync;
  66445. private _getEventAction;
  66446. private _loadAnimationEventAsync;
  66447. }
  66448. }
  66449. declare module BABYLON.GLTF2.Loader.Extensions {
  66450. /**
  66451. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66452. */
  66453. export class MSFT_lod implements IGLTFLoaderExtension {
  66454. /** The name of this extension. */
  66455. readonly name: string;
  66456. /** Defines whether this extension is enabled. */
  66457. enabled: boolean;
  66458. /**
  66459. * Maximum number of LODs to load, starting from the lowest LOD.
  66460. */
  66461. maxLODsToLoad: number;
  66462. /**
  66463. * Observable raised when all node LODs of one level are loaded.
  66464. * The event data is the index of the loaded LOD starting from zero.
  66465. * Dispose the loader to cancel the loading of the next level of LODs.
  66466. */
  66467. onNodeLODsLoadedObservable: Observable<number>;
  66468. /**
  66469. * Observable raised when all material LODs of one level are loaded.
  66470. * The event data is the index of the loaded LOD starting from zero.
  66471. * Dispose the loader to cancel the loading of the next level of LODs.
  66472. */
  66473. onMaterialLODsLoadedObservable: Observable<number>;
  66474. private _loader;
  66475. private _nodeIndexLOD;
  66476. private _nodeSignalLODs;
  66477. private _nodePromiseLODs;
  66478. private _materialIndexLOD;
  66479. private _materialSignalLODs;
  66480. private _materialPromiseLODs;
  66481. /** @hidden */
  66482. constructor(loader: GLTFLoader);
  66483. /** @hidden */
  66484. dispose(): void;
  66485. /** @hidden */
  66486. onReady(): void;
  66487. /** @hidden */
  66488. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66489. /** @hidden */
  66490. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66491. /** @hidden */
  66492. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66493. /**
  66494. * Gets an array of LOD properties from lowest to highest.
  66495. */
  66496. private _getLODs;
  66497. private _disposeUnusedMaterials;
  66498. }
  66499. }
  66500. declare module BABYLON.GLTF2.Loader.Extensions {
  66501. /** @hidden */
  66502. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66503. readonly name: string;
  66504. enabled: boolean;
  66505. private _loader;
  66506. constructor(loader: GLTFLoader);
  66507. dispose(): void;
  66508. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66509. }
  66510. }
  66511. declare module BABYLON.GLTF2.Loader.Extensions {
  66512. /** @hidden */
  66513. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66514. readonly name: string;
  66515. enabled: boolean;
  66516. private _loader;
  66517. constructor(loader: GLTFLoader);
  66518. dispose(): void;
  66519. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66520. }
  66521. }
  66522. declare module BABYLON.GLTF2.Loader.Extensions {
  66523. /**
  66524. * Store glTF extras (if present) in BJS objects' metadata
  66525. */
  66526. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66527. /** The name of this extension. */
  66528. readonly name: string;
  66529. /** Defines whether this extension is enabled. */
  66530. enabled: boolean;
  66531. private _loader;
  66532. private _assignExtras;
  66533. /** @hidden */
  66534. constructor(loader: GLTFLoader);
  66535. /** @hidden */
  66536. dispose(): void;
  66537. /** @hidden */
  66538. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66539. /** @hidden */
  66540. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66541. /** @hidden */
  66542. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66543. }
  66544. }
  66545. declare module BABYLON {
  66546. /**
  66547. * Class reading and parsing the MTL file bundled with the obj file.
  66548. */
  66549. export class MTLFileLoader {
  66550. /**
  66551. * All material loaded from the mtl will be set here
  66552. */
  66553. materials: StandardMaterial[];
  66554. /**
  66555. * This function will read the mtl file and create each material described inside
  66556. * This function could be improve by adding :
  66557. * -some component missing (Ni, Tf...)
  66558. * -including the specific options available
  66559. *
  66560. * @param scene defines the scene the material will be created in
  66561. * @param data defines the mtl data to parse
  66562. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66563. */
  66564. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66565. /**
  66566. * Gets the texture for the material.
  66567. *
  66568. * If the material is imported from input file,
  66569. * We sanitize the url to ensure it takes the textre from aside the material.
  66570. *
  66571. * @param rootUrl The root url to load from
  66572. * @param value The value stored in the mtl
  66573. * @return The Texture
  66574. */
  66575. private static _getTexture;
  66576. }
  66577. /**
  66578. * Options for loading OBJ/MTL files
  66579. */
  66580. type MeshLoadOptions = {
  66581. /**
  66582. * Defines if UVs are optimized by default during load.
  66583. */
  66584. OptimizeWithUV: boolean;
  66585. /**
  66586. * Defines custom scaling of UV coordinates of loaded meshes.
  66587. */
  66588. UVScaling: Vector2;
  66589. /**
  66590. * Invert model on y-axis (does a model scaling inversion)
  66591. */
  66592. InvertY: boolean;
  66593. /**
  66594. * Invert Y-Axis of referenced textures on load
  66595. */
  66596. InvertTextureY: boolean;
  66597. /**
  66598. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66599. */
  66600. ImportVertexColors: boolean;
  66601. /**
  66602. * Compute the normals for the model, even if normals are present in the file.
  66603. */
  66604. ComputeNormals: boolean;
  66605. /**
  66606. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66607. */
  66608. SkipMaterials: boolean;
  66609. /**
  66610. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66611. */
  66612. MaterialLoadingFailsSilently: boolean;
  66613. };
  66614. /**
  66615. * OBJ file type loader.
  66616. * This is a babylon scene loader plugin.
  66617. */
  66618. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66619. /**
  66620. * Defines if UVs are optimized by default during load.
  66621. */
  66622. static OPTIMIZE_WITH_UV: boolean;
  66623. /**
  66624. * Invert model on y-axis (does a model scaling inversion)
  66625. */
  66626. static INVERT_Y: boolean;
  66627. /**
  66628. * Invert Y-Axis of referenced textures on load
  66629. */
  66630. static INVERT_TEXTURE_Y: boolean;
  66631. /**
  66632. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66633. */
  66634. static IMPORT_VERTEX_COLORS: boolean;
  66635. /**
  66636. * Compute the normals for the model, even if normals are present in the file.
  66637. */
  66638. static COMPUTE_NORMALS: boolean;
  66639. /**
  66640. * Defines custom scaling of UV coordinates of loaded meshes.
  66641. */
  66642. static UV_SCALING: Vector2;
  66643. /**
  66644. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66645. */
  66646. static SKIP_MATERIALS: boolean;
  66647. /**
  66648. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66649. *
  66650. * Defaults to true for backwards compatibility.
  66651. */
  66652. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66653. /**
  66654. * Defines the name of the plugin.
  66655. */
  66656. name: string;
  66657. /**
  66658. * Defines the extension the plugin is able to load.
  66659. */
  66660. extensions: string;
  66661. /** @hidden */
  66662. obj: RegExp;
  66663. /** @hidden */
  66664. group: RegExp;
  66665. /** @hidden */
  66666. mtllib: RegExp;
  66667. /** @hidden */
  66668. usemtl: RegExp;
  66669. /** @hidden */
  66670. smooth: RegExp;
  66671. /** @hidden */
  66672. vertexPattern: RegExp;
  66673. /** @hidden */
  66674. normalPattern: RegExp;
  66675. /** @hidden */
  66676. uvPattern: RegExp;
  66677. /** @hidden */
  66678. facePattern1: RegExp;
  66679. /** @hidden */
  66680. facePattern2: RegExp;
  66681. /** @hidden */
  66682. facePattern3: RegExp;
  66683. /** @hidden */
  66684. facePattern4: RegExp;
  66685. /** @hidden */
  66686. facePattern5: RegExp;
  66687. private _meshLoadOptions;
  66688. /**
  66689. * Creates loader for .OBJ files
  66690. *
  66691. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66692. */
  66693. constructor(meshLoadOptions?: MeshLoadOptions);
  66694. private static readonly currentMeshLoadOptions;
  66695. /**
  66696. * Calls synchronously the MTL file attached to this obj.
  66697. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66698. * Without this function materials are not displayed in the first frame (but displayed after).
  66699. * In consequence it is impossible to get material information in your HTML file
  66700. *
  66701. * @param url The URL of the MTL file
  66702. * @param rootUrl
  66703. * @param onSuccess Callback function to be called when the MTL file is loaded
  66704. * @private
  66705. */
  66706. private _loadMTL;
  66707. /**
  66708. * Instantiates a OBJ file loader plugin.
  66709. * @returns the created plugin
  66710. */
  66711. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  66712. /**
  66713. * If the data string can be loaded directly.
  66714. *
  66715. * @param data string containing the file data
  66716. * @returns if the data can be loaded directly
  66717. */
  66718. canDirectLoad(data: string): boolean;
  66719. /**
  66720. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  66721. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66722. * @param scene the scene the meshes should be added to
  66723. * @param data the OBJ data to load
  66724. * @param rootUrl root url to load from
  66725. * @param onProgress event that fires when loading progress has occured
  66726. * @param fileName Defines the name of the file to load
  66727. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66728. */
  66729. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66730. meshes: AbstractMesh[];
  66731. particleSystems: IParticleSystem[];
  66732. skeletons: Skeleton[];
  66733. animationGroups: AnimationGroup[];
  66734. }>;
  66735. /**
  66736. * Imports all objects from the loaded OBJ data and adds them to the scene
  66737. * @param scene the scene the objects should be added to
  66738. * @param data the OBJ data to load
  66739. * @param rootUrl root url to load from
  66740. * @param onProgress event that fires when loading progress has occured
  66741. * @param fileName Defines the name of the file to load
  66742. * @returns a promise which completes when objects have been loaded to the scene
  66743. */
  66744. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66745. /**
  66746. * Load into an asset container.
  66747. * @param scene The scene to load into
  66748. * @param data The data to import
  66749. * @param rootUrl The root url for scene and resources
  66750. * @param onProgress The callback when the load progresses
  66751. * @param fileName Defines the name of the file to load
  66752. * @returns The loaded asset container
  66753. */
  66754. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66755. /**
  66756. * Read the OBJ file and create an Array of meshes.
  66757. * Each mesh contains all information given by the OBJ and the MTL file.
  66758. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66759. *
  66760. * @param meshesNames
  66761. * @param scene Scene The scene where are displayed the data
  66762. * @param data String The content of the obj file
  66763. * @param rootUrl String The path to the folder
  66764. * @returns Array<AbstractMesh>
  66765. * @private
  66766. */
  66767. private _parseSolid;
  66768. }
  66769. }
  66770. declare module BABYLON {
  66771. /**
  66772. * STL file type loader.
  66773. * This is a babylon scene loader plugin.
  66774. */
  66775. export class STLFileLoader implements ISceneLoaderPlugin {
  66776. /** @hidden */
  66777. solidPattern: RegExp;
  66778. /** @hidden */
  66779. facetsPattern: RegExp;
  66780. /** @hidden */
  66781. normalPattern: RegExp;
  66782. /** @hidden */
  66783. vertexPattern: RegExp;
  66784. /**
  66785. * Defines the name of the plugin.
  66786. */
  66787. name: string;
  66788. /**
  66789. * Defines the extensions the stl loader is able to load.
  66790. * force data to come in as an ArrayBuffer
  66791. * we'll convert to string if it looks like it's an ASCII .stl
  66792. */
  66793. extensions: ISceneLoaderPluginExtensions;
  66794. /**
  66795. * Import meshes into a scene.
  66796. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66797. * @param scene The scene to import into
  66798. * @param data The data to import
  66799. * @param rootUrl The root url for scene and resources
  66800. * @param meshes The meshes array to import into
  66801. * @param particleSystems The particle systems array to import into
  66802. * @param skeletons The skeletons array to import into
  66803. * @param onError The callback when import fails
  66804. * @returns True if successful or false otherwise
  66805. */
  66806. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66807. /**
  66808. * Load into a scene.
  66809. * @param scene The scene to load into
  66810. * @param data The data to import
  66811. * @param rootUrl The root url for scene and resources
  66812. * @param onError The callback when import fails
  66813. * @returns true if successful or false otherwise
  66814. */
  66815. load(scene: Scene, data: any, rootUrl: string): boolean;
  66816. /**
  66817. * Load into an asset container.
  66818. * @param scene The scene to load into
  66819. * @param data The data to import
  66820. * @param rootUrl The root url for scene and resources
  66821. * @param onError The callback when import fails
  66822. * @returns The loaded asset container
  66823. */
  66824. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66825. private _isBinary;
  66826. private _parseBinary;
  66827. private _parseASCII;
  66828. }
  66829. }
  66830. declare module BABYLON {
  66831. /**
  66832. * Class for generating OBJ data from a Babylon scene.
  66833. */
  66834. export class OBJExport {
  66835. /**
  66836. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66837. * @param mesh defines the list of meshes to serialize
  66838. * @param materials defines if materials should be exported
  66839. * @param matlibname defines the name of the associated mtl file
  66840. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66841. * @returns the OBJ content
  66842. */
  66843. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66844. /**
  66845. * Exports the material(s) of a mesh in .MTL file format (text)
  66846. * @param mesh defines the mesh to extract the material from
  66847. * @returns the mtl content
  66848. */
  66849. static MTL(mesh: Mesh): string;
  66850. }
  66851. }
  66852. declare module BABYLON {
  66853. /** @hidden */
  66854. export var __IGLTFExporterExtension: number;
  66855. /**
  66856. * Interface for extending the exporter
  66857. * @hidden
  66858. */
  66859. export interface IGLTFExporterExtension {
  66860. /**
  66861. * The name of this extension
  66862. */
  66863. readonly name: string;
  66864. /**
  66865. * Defines whether this extension is enabled
  66866. */
  66867. enabled: boolean;
  66868. /**
  66869. * Defines whether this extension is required
  66870. */
  66871. required: boolean;
  66872. }
  66873. }
  66874. declare module BABYLON.GLTF2.Exporter {
  66875. /** @hidden */
  66876. export var __IGLTFExporterExtensionV2: number;
  66877. /**
  66878. * Interface for a glTF exporter extension
  66879. * @hidden
  66880. */
  66881. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66882. /**
  66883. * Define this method to modify the default behavior before exporting a texture
  66884. * @param context The context when loading the asset
  66885. * @param babylonTexture The glTF texture info property
  66886. * @param mimeType The mime-type of the generated image
  66887. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66888. */
  66889. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66890. /**
  66891. * Define this method to modify the default behavior when exporting texture info
  66892. * @param context The context when loading the asset
  66893. * @param meshPrimitive glTF mesh primitive
  66894. * @param babylonSubMesh Babylon submesh
  66895. * @param binaryWriter glTF serializer binary writer instance
  66896. * @returns nullable IMeshPrimitive promise
  66897. */
  66898. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66899. /**
  66900. * Define this method to modify the default behavior when exporting a node
  66901. * @param context The context when exporting the node
  66902. * @param node glTF node
  66903. * @param babylonNode BabylonJS node
  66904. * @returns nullable INode promise
  66905. */
  66906. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66907. /**
  66908. * Called after the exporter state changes to EXPORTING
  66909. */
  66910. onExporting?(): void;
  66911. }
  66912. }
  66913. declare module BABYLON.GLTF2.Exporter {
  66914. /**
  66915. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66916. * @hidden
  66917. */
  66918. export class _GLTFMaterialExporter {
  66919. /**
  66920. * Represents the dielectric specular values for R, G and B
  66921. */
  66922. private static readonly _DielectricSpecular;
  66923. /**
  66924. * Allows the maximum specular power to be defined for material calculations
  66925. */
  66926. private static readonly _MaxSpecularPower;
  66927. /**
  66928. * Mapping to store textures
  66929. */
  66930. private _textureMap;
  66931. /**
  66932. * Numeric tolerance value
  66933. */
  66934. private static readonly _Epsilon;
  66935. /**
  66936. * Reference to the glTF Exporter
  66937. */
  66938. private _exporter;
  66939. constructor(exporter: _Exporter);
  66940. /**
  66941. * Specifies if two colors are approximately equal in value
  66942. * @param color1 first color to compare to
  66943. * @param color2 second color to compare to
  66944. * @param epsilon threshold value
  66945. */
  66946. private static FuzzyEquals;
  66947. /**
  66948. * Gets the materials from a Babylon scene and converts them to glTF materials
  66949. * @param scene babylonjs scene
  66950. * @param mimeType texture mime type
  66951. * @param images array of images
  66952. * @param textures array of textures
  66953. * @param materials array of materials
  66954. * @param imageData mapping of texture names to base64 textures
  66955. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66956. */
  66957. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66958. /**
  66959. * Makes a copy of the glTF material without the texture parameters
  66960. * @param originalMaterial original glTF material
  66961. * @returns glTF material without texture parameters
  66962. */
  66963. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66964. /**
  66965. * Specifies if the material has any texture parameters present
  66966. * @param material glTF Material
  66967. * @returns boolean specifying if texture parameters are present
  66968. */
  66969. _hasTexturesPresent(material: IMaterial): boolean;
  66970. /**
  66971. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66972. * @param babylonStandardMaterial
  66973. * @returns glTF Metallic Roughness Material representation
  66974. */
  66975. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66976. /**
  66977. * Computes the metallic factor
  66978. * @param diffuse diffused value
  66979. * @param specular specular value
  66980. * @param oneMinusSpecularStrength one minus the specular strength
  66981. * @returns metallic value
  66982. */
  66983. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66984. /**
  66985. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66986. * @param glTFMaterial glTF material
  66987. * @param babylonMaterial Babylon material
  66988. */
  66989. private static _SetAlphaMode;
  66990. /**
  66991. * Converts a Babylon Standard Material to a glTF Material
  66992. * @param babylonStandardMaterial BJS Standard Material
  66993. * @param mimeType mime type to use for the textures
  66994. * @param images array of glTF image interfaces
  66995. * @param textures array of glTF texture interfaces
  66996. * @param materials array of glTF material interfaces
  66997. * @param imageData map of image file name to data
  66998. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66999. */
  67000. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67001. /**
  67002. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67003. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67004. * @param mimeType mime type to use for the textures
  67005. * @param images array of glTF image interfaces
  67006. * @param textures array of glTF texture interfaces
  67007. * @param materials array of glTF material interfaces
  67008. * @param imageData map of image file name to data
  67009. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67010. */
  67011. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67012. /**
  67013. * Converts an image typed array buffer to a base64 image
  67014. * @param buffer typed array buffer
  67015. * @param width width of the image
  67016. * @param height height of the image
  67017. * @param mimeType mimetype of the image
  67018. * @returns base64 image string
  67019. */
  67020. private _createBase64FromCanvasAsync;
  67021. /**
  67022. * Generates a white texture based on the specified width and height
  67023. * @param width width of the texture in pixels
  67024. * @param height height of the texture in pixels
  67025. * @param scene babylonjs scene
  67026. * @returns white texture
  67027. */
  67028. private _createWhiteTexture;
  67029. /**
  67030. * 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
  67031. * @param texture1 first texture to resize
  67032. * @param texture2 second texture to resize
  67033. * @param scene babylonjs scene
  67034. * @returns resized textures or null
  67035. */
  67036. private _resizeTexturesToSameDimensions;
  67037. /**
  67038. * Converts an array of pixels to a Float32Array
  67039. * Throws an error if the pixel format is not supported
  67040. * @param pixels - array buffer containing pixel values
  67041. * @returns Float32 of pixels
  67042. */
  67043. private _convertPixelArrayToFloat32;
  67044. /**
  67045. * Convert Specular Glossiness Textures to Metallic Roughness
  67046. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67047. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67048. * @param diffuseTexture texture used to store diffuse information
  67049. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67050. * @param factors specular glossiness material factors
  67051. * @param mimeType the mime type to use for the texture
  67052. * @returns pbr metallic roughness interface or null
  67053. */
  67054. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67055. /**
  67056. * Converts specular glossiness material properties to metallic roughness
  67057. * @param specularGlossiness interface with specular glossiness material properties
  67058. * @returns interface with metallic roughness material properties
  67059. */
  67060. private _convertSpecularGlossinessToMetallicRoughness;
  67061. /**
  67062. * Calculates the surface reflectance, independent of lighting conditions
  67063. * @param color Color source to calculate brightness from
  67064. * @returns number representing the perceived brightness, or zero if color is undefined
  67065. */
  67066. private _getPerceivedBrightness;
  67067. /**
  67068. * Returns the maximum color component value
  67069. * @param color
  67070. * @returns maximum color component value, or zero if color is null or undefined
  67071. */
  67072. private _getMaxComponent;
  67073. /**
  67074. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67075. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67076. * @param mimeType mime type to use for the textures
  67077. * @param images array of glTF image interfaces
  67078. * @param textures array of glTF texture interfaces
  67079. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67080. * @param imageData map of image file name to data
  67081. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67082. * @returns glTF PBR Metallic Roughness factors
  67083. */
  67084. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67085. private _getGLTFTextureSampler;
  67086. private _getGLTFTextureWrapMode;
  67087. private _getGLTFTextureWrapModesSampler;
  67088. /**
  67089. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67090. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67091. * @param mimeType mime type to use for the textures
  67092. * @param images array of glTF image interfaces
  67093. * @param textures array of glTF texture interfaces
  67094. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67095. * @param imageData map of image file name to data
  67096. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67097. * @returns glTF PBR Metallic Roughness factors
  67098. */
  67099. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67100. /**
  67101. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67102. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67103. * @param mimeType mime type to use for the textures
  67104. * @param images array of glTF image interfaces
  67105. * @param textures array of glTF texture interfaces
  67106. * @param materials array of glTF material interfaces
  67107. * @param imageData map of image file name to data
  67108. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67109. */
  67110. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67111. private setMetallicRoughnessPbrMaterial;
  67112. private getPixelsFromTexture;
  67113. /**
  67114. * Extracts a texture from a Babylon texture into file data and glTF data
  67115. * @param babylonTexture Babylon texture to extract
  67116. * @param mimeType Mime Type of the babylonTexture
  67117. * @return glTF texture info, or null if the texture format is not supported
  67118. */
  67119. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67120. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67121. /**
  67122. * Builds a texture from base64 string
  67123. * @param base64Texture base64 texture string
  67124. * @param baseTextureName Name to use for the texture
  67125. * @param mimeType image mime type for the texture
  67126. * @param images array of images
  67127. * @param textures array of textures
  67128. * @param imageData map of image data
  67129. * @returns glTF texture info, or null if the texture format is not supported
  67130. */
  67131. private _getTextureInfoFromBase64;
  67132. }
  67133. }
  67134. declare module BABYLON {
  67135. /**
  67136. * Class for holding and downloading glTF file data
  67137. */
  67138. export class GLTFData {
  67139. /**
  67140. * Object which contains the file name as the key and its data as the value
  67141. */
  67142. glTFFiles: {
  67143. [fileName: string]: string | Blob;
  67144. };
  67145. /**
  67146. * Initializes the glTF file object
  67147. */
  67148. constructor();
  67149. /**
  67150. * Downloads the glTF data as files based on their names and data
  67151. */
  67152. downloadFiles(): void;
  67153. }
  67154. }
  67155. declare module BABYLON {
  67156. /**
  67157. * Holds a collection of exporter options and parameters
  67158. */
  67159. export interface IExportOptions {
  67160. /**
  67161. * Function which indicates whether a babylon node should be exported or not
  67162. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67163. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67164. */
  67165. shouldExportNode?(node: Node): boolean;
  67166. /**
  67167. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67168. * @param metadata source metadata to read from
  67169. * @returns the data to store to glTF node extras
  67170. */
  67171. metadataSelector?(metadata: any): any;
  67172. /**
  67173. * The sample rate to bake animation curves
  67174. */
  67175. animationSampleRate?: number;
  67176. /**
  67177. * Begin serialization without waiting for the scene to be ready
  67178. */
  67179. exportWithoutWaitingForScene?: boolean;
  67180. }
  67181. /**
  67182. * Class for generating glTF data from a Babylon scene.
  67183. */
  67184. export class GLTF2Export {
  67185. /**
  67186. * Exports the geometry of the scene to .gltf file format asynchronously
  67187. * @param scene Babylon scene with scene hierarchy information
  67188. * @param filePrefix File prefix to use when generating the glTF file
  67189. * @param options Exporter options
  67190. * @returns Returns an object with a .gltf file and associates texture names
  67191. * as keys and their data and paths as values
  67192. */
  67193. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67194. private static _PreExportAsync;
  67195. private static _PostExportAsync;
  67196. /**
  67197. * Exports the geometry of the scene to .glb file format asychronously
  67198. * @param scene Babylon scene with scene hierarchy information
  67199. * @param filePrefix File prefix to use when generating glb file
  67200. * @param options Exporter options
  67201. * @returns Returns an object with a .glb filename as key and data as value
  67202. */
  67203. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67204. }
  67205. }
  67206. declare module BABYLON.GLTF2.Exporter {
  67207. /**
  67208. * @hidden
  67209. */
  67210. export class _GLTFUtilities {
  67211. /**
  67212. * Creates a buffer view based on the supplied arguments
  67213. * @param bufferIndex index value of the specified buffer
  67214. * @param byteOffset byte offset value
  67215. * @param byteLength byte length of the bufferView
  67216. * @param byteStride byte distance between conequential elements
  67217. * @param name name of the buffer view
  67218. * @returns bufferView for glTF
  67219. */
  67220. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67221. /**
  67222. * Creates an accessor based on the supplied arguments
  67223. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67224. * @param name The name of the accessor
  67225. * @param type The type of the accessor
  67226. * @param componentType The datatype of components in the attribute
  67227. * @param count The number of attributes referenced by this accessor
  67228. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67229. * @param min Minimum value of each component in this attribute
  67230. * @param max Maximum value of each component in this attribute
  67231. * @returns accessor for glTF
  67232. */
  67233. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67234. /**
  67235. * Calculates the minimum and maximum values of an array of position floats
  67236. * @param positions Positions array of a mesh
  67237. * @param vertexStart Starting vertex offset to calculate min and max values
  67238. * @param vertexCount Number of vertices to check for min and max values
  67239. * @returns min number array and max number array
  67240. */
  67241. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67242. min: number[];
  67243. max: number[];
  67244. };
  67245. /**
  67246. * Converts a new right-handed Vector3
  67247. * @param vector vector3 array
  67248. * @returns right-handed Vector3
  67249. */
  67250. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67251. /**
  67252. * Converts a Vector3 to right-handed
  67253. * @param vector Vector3 to convert to right-handed
  67254. */
  67255. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67256. /**
  67257. * Converts a three element number array to right-handed
  67258. * @param vector number array to convert to right-handed
  67259. */
  67260. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67261. /**
  67262. * Converts a new right-handed Vector3
  67263. * @param vector vector3 array
  67264. * @returns right-handed Vector3
  67265. */
  67266. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67267. /**
  67268. * Converts a Vector3 to right-handed
  67269. * @param vector Vector3 to convert to right-handed
  67270. */
  67271. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67272. /**
  67273. * Converts a three element number array to right-handed
  67274. * @param vector number array to convert to right-handed
  67275. */
  67276. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67277. /**
  67278. * Converts a Vector4 to right-handed
  67279. * @param vector Vector4 to convert to right-handed
  67280. */
  67281. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67282. /**
  67283. * Converts a Vector4 to right-handed
  67284. * @param vector Vector4 to convert to right-handed
  67285. */
  67286. static _GetRightHandedArray4FromRef(vector: number[]): void;
  67287. /**
  67288. * Converts a Quaternion to right-handed
  67289. * @param quaternion Source quaternion to convert to right-handed
  67290. */
  67291. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67292. /**
  67293. * Converts a Quaternion to right-handed
  67294. * @param quaternion Source quaternion to convert to right-handed
  67295. */
  67296. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  67297. static _NormalizeTangentFromRef(tangent: Vector4): void;
  67298. }
  67299. }
  67300. declare module BABYLON.GLTF2.Exporter {
  67301. /**
  67302. * Converts Babylon Scene into glTF 2.0.
  67303. * @hidden
  67304. */
  67305. export class _Exporter {
  67306. /**
  67307. * Stores the glTF to export
  67308. */
  67309. _glTF: IGLTF;
  67310. /**
  67311. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67312. */
  67313. _bufferViews: IBufferView[];
  67314. /**
  67315. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67316. */
  67317. _accessors: IAccessor[];
  67318. /**
  67319. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67320. */
  67321. private _nodes;
  67322. /**
  67323. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67324. */
  67325. private _scenes;
  67326. /**
  67327. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67328. */
  67329. private _meshes;
  67330. /**
  67331. * Stores all the generated material information, which represents the appearance of each primitive
  67332. */
  67333. _materials: IMaterial[];
  67334. _materialMap: {
  67335. [materialID: number]: number;
  67336. };
  67337. /**
  67338. * Stores all the generated texture information, which is referenced by glTF materials
  67339. */
  67340. _textures: ITexture[];
  67341. /**
  67342. * Stores all the generated image information, which is referenced by glTF textures
  67343. */
  67344. _images: IImage[];
  67345. /**
  67346. * Stores all the texture samplers
  67347. */
  67348. _samplers: ISampler[];
  67349. /**
  67350. * Stores all the generated animation samplers, which is referenced by glTF animations
  67351. */
  67352. /**
  67353. * Stores the animations for glTF models
  67354. */
  67355. private _animations;
  67356. /**
  67357. * Stores the total amount of bytes stored in the glTF buffer
  67358. */
  67359. private _totalByteLength;
  67360. /**
  67361. * Stores a reference to the Babylon scene containing the source geometry and material information
  67362. */
  67363. _babylonScene: Scene;
  67364. /**
  67365. * Stores a map of the image data, where the key is the file name and the value
  67366. * is the image data
  67367. */
  67368. _imageData: {
  67369. [fileName: string]: {
  67370. data: Uint8Array;
  67371. mimeType: ImageMimeType;
  67372. };
  67373. };
  67374. /**
  67375. * Stores a map of the unique id of a node to its index in the node array
  67376. */
  67377. private _nodeMap;
  67378. /**
  67379. * Specifies if the Babylon scene should be converted to right-handed on export
  67380. */
  67381. _convertToRightHandedSystem: boolean;
  67382. /**
  67383. * Baked animation sample rate
  67384. */
  67385. private _animationSampleRate;
  67386. private _options;
  67387. private _localEngine;
  67388. _glTFMaterialExporter: _GLTFMaterialExporter;
  67389. private _extensions;
  67390. private static _ExtensionNames;
  67391. private static _ExtensionFactories;
  67392. private _applyExtensions;
  67393. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  67394. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67395. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67396. private _forEachExtensions;
  67397. private _extensionsOnExporting;
  67398. /**
  67399. * Load glTF serializer extensions
  67400. */
  67401. private _loadExtensions;
  67402. /**
  67403. * Creates a glTF Exporter instance, which can accept optional exporter options
  67404. * @param babylonScene Babylon scene object
  67405. * @param options Options to modify the behavior of the exporter
  67406. */
  67407. constructor(babylonScene: Scene, options?: IExportOptions);
  67408. /**
  67409. * Registers a glTF exporter extension
  67410. * @param name Name of the extension to export
  67411. * @param factory The factory function that creates the exporter extension
  67412. */
  67413. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67414. /**
  67415. * Un-registers an exporter extension
  67416. * @param name The name fo the exporter extension
  67417. * @returns A boolean indicating whether the extension has been un-registered
  67418. */
  67419. static UnregisterExtension(name: string): boolean;
  67420. /**
  67421. * Lazy load a local engine with premultiplied alpha set to false
  67422. */
  67423. _getLocalEngine(): Engine;
  67424. private reorderIndicesBasedOnPrimitiveMode;
  67425. /**
  67426. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67427. * clock-wise during export to glTF
  67428. * @param submesh BabylonJS submesh
  67429. * @param primitiveMode Primitive mode of the mesh
  67430. * @param sideOrientation the winding order of the submesh
  67431. * @param vertexBufferKind The type of vertex attribute
  67432. * @param meshAttributeArray The vertex attribute data
  67433. * @param byteOffset The offset to the binary data
  67434. * @param binaryWriter The binary data for the glTF file
  67435. */
  67436. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67437. /**
  67438. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67439. * clock-wise during export to glTF
  67440. * @param submesh BabylonJS submesh
  67441. * @param primitiveMode Primitive mode of the mesh
  67442. * @param sideOrientation the winding order of the submesh
  67443. * @param vertexBufferKind The type of vertex attribute
  67444. * @param meshAttributeArray The vertex attribute data
  67445. * @param byteOffset The offset to the binary data
  67446. * @param binaryWriter The binary data for the glTF file
  67447. */
  67448. private reorderTriangleFillMode;
  67449. /**
  67450. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67451. * clock-wise during export to glTF
  67452. * @param submesh BabylonJS submesh
  67453. * @param primitiveMode Primitive mode of the mesh
  67454. * @param sideOrientation the winding order of the submesh
  67455. * @param vertexBufferKind The type of vertex attribute
  67456. * @param meshAttributeArray The vertex attribute data
  67457. * @param byteOffset The offset to the binary data
  67458. * @param binaryWriter The binary data for the glTF file
  67459. */
  67460. private reorderTriangleStripDrawMode;
  67461. /**
  67462. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67463. * clock-wise during export to glTF
  67464. * @param submesh BabylonJS submesh
  67465. * @param primitiveMode Primitive mode of the mesh
  67466. * @param sideOrientation the winding order of the submesh
  67467. * @param vertexBufferKind The type of vertex attribute
  67468. * @param meshAttributeArray The vertex attribute data
  67469. * @param byteOffset The offset to the binary data
  67470. * @param binaryWriter The binary data for the glTF file
  67471. */
  67472. private reorderTriangleFanMode;
  67473. /**
  67474. * Writes the vertex attribute data to binary
  67475. * @param vertices The vertices to write to the binary writer
  67476. * @param byteOffset The offset into the binary writer to overwrite binary data
  67477. * @param vertexAttributeKind The vertex attribute type
  67478. * @param meshAttributeArray The vertex attribute data
  67479. * @param binaryWriter The writer containing the binary data
  67480. */
  67481. private writeVertexAttributeData;
  67482. /**
  67483. * Writes mesh attribute data to a data buffer
  67484. * Returns the bytelength of the data
  67485. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67486. * @param meshAttributeArray Array containing the attribute data
  67487. * @param binaryWriter The buffer to write the binary data to
  67488. * @param indices Used to specify the order of the vertex data
  67489. */
  67490. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67491. /**
  67492. * Generates glTF json data
  67493. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67494. * @param glTFPrefix Text to use when prefixing a glTF file
  67495. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67496. * @returns json data as string
  67497. */
  67498. private generateJSON;
  67499. /**
  67500. * Generates data for .gltf and .bin files based on the glTF prefix string
  67501. * @param glTFPrefix Text to use when prefixing a glTF file
  67502. * @returns GLTFData with glTF file data
  67503. */
  67504. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67505. /**
  67506. * Creates a binary buffer for glTF
  67507. * @returns array buffer for binary data
  67508. */
  67509. private _generateBinaryAsync;
  67510. /**
  67511. * Pads the number to a multiple of 4
  67512. * @param num number to pad
  67513. * @returns padded number
  67514. */
  67515. private _getPadding;
  67516. /**
  67517. * Generates a glb file from the json and binary data
  67518. * Returns an object with the glb file name as the key and data as the value
  67519. * @param glTFPrefix
  67520. * @returns object with glb filename as key and data as value
  67521. */
  67522. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67523. /**
  67524. * Sets the TRS for each node
  67525. * @param node glTF Node for storing the transformation data
  67526. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67527. */
  67528. private setNodeTransformation;
  67529. private getVertexBufferFromMesh;
  67530. /**
  67531. * Creates a bufferview based on the vertices type for the Babylon mesh
  67532. * @param kind Indicates the type of vertices data
  67533. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67534. * @param binaryWriter The buffer to write the bufferview data to
  67535. */
  67536. private createBufferViewKind;
  67537. /**
  67538. * The primitive mode of the Babylon mesh
  67539. * @param babylonMesh The BabylonJS mesh
  67540. */
  67541. private getMeshPrimitiveMode;
  67542. /**
  67543. * Sets the primitive mode of the glTF mesh primitive
  67544. * @param meshPrimitive glTF mesh primitive
  67545. * @param primitiveMode The primitive mode
  67546. */
  67547. private setPrimitiveMode;
  67548. /**
  67549. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67550. * @param meshPrimitive glTF mesh primitive
  67551. * @param attributeKind vertex attribute
  67552. * @returns boolean specifying if uv coordinates are present
  67553. */
  67554. private setAttributeKind;
  67555. /**
  67556. * Sets data for the primitive attributes of each submesh
  67557. * @param mesh glTF Mesh object to store the primitive attribute information
  67558. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67559. * @param binaryWriter Buffer to write the attribute data to
  67560. */
  67561. private setPrimitiveAttributesAsync;
  67562. /**
  67563. * Creates a glTF scene based on the array of meshes
  67564. * Returns the the total byte offset
  67565. * @param babylonScene Babylon scene to get the mesh data from
  67566. * @param binaryWriter Buffer to write binary data to
  67567. */
  67568. private createSceneAsync;
  67569. /**
  67570. * Creates a mapping of Node unique id to node index and handles animations
  67571. * @param babylonScene Babylon Scene
  67572. * @param nodes Babylon transform nodes
  67573. * @param binaryWriter Buffer to write binary data to
  67574. * @returns Node mapping of unique id to index
  67575. */
  67576. private createNodeMapAndAnimationsAsync;
  67577. /**
  67578. * Creates a glTF node from a Babylon mesh
  67579. * @param babylonMesh Source Babylon mesh
  67580. * @param binaryWriter Buffer for storing geometry data
  67581. * @returns glTF node
  67582. */
  67583. private createNodeAsync;
  67584. }
  67585. /**
  67586. * @hidden
  67587. *
  67588. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67589. */
  67590. export class _BinaryWriter {
  67591. /**
  67592. * Array buffer which stores all binary data
  67593. */
  67594. private _arrayBuffer;
  67595. /**
  67596. * View of the array buffer
  67597. */
  67598. private _dataView;
  67599. /**
  67600. * byte offset of data in array buffer
  67601. */
  67602. private _byteOffset;
  67603. /**
  67604. * Initialize binary writer with an initial byte length
  67605. * @param byteLength Initial byte length of the array buffer
  67606. */
  67607. constructor(byteLength: number);
  67608. /**
  67609. * Resize the array buffer to the specified byte length
  67610. * @param byteLength
  67611. */
  67612. private resizeBuffer;
  67613. /**
  67614. * Get an array buffer with the length of the byte offset
  67615. * @returns ArrayBuffer resized to the byte offset
  67616. */
  67617. getArrayBuffer(): ArrayBuffer;
  67618. /**
  67619. * Get the byte offset of the array buffer
  67620. * @returns byte offset
  67621. */
  67622. getByteOffset(): number;
  67623. /**
  67624. * Stores an UInt8 in the array buffer
  67625. * @param entry
  67626. * @param byteOffset If defined, specifies where to set the value as an offset.
  67627. */
  67628. setUInt8(entry: number, byteOffset?: number): void;
  67629. /**
  67630. * Gets an UInt32 in the array buffer
  67631. * @param entry
  67632. * @param byteOffset If defined, specifies where to set the value as an offset.
  67633. */
  67634. getUInt32(byteOffset: number): number;
  67635. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67636. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67637. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67638. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67639. /**
  67640. * Stores a Float32 in the array buffer
  67641. * @param entry
  67642. */
  67643. setFloat32(entry: number, byteOffset?: number): void;
  67644. /**
  67645. * Stores an UInt32 in the array buffer
  67646. * @param entry
  67647. * @param byteOffset If defined, specifies where to set the value as an offset.
  67648. */
  67649. setUInt32(entry: number, byteOffset?: number): void;
  67650. }
  67651. }
  67652. declare module BABYLON.GLTF2.Exporter {
  67653. /**
  67654. * @hidden
  67655. * Interface to store animation data.
  67656. */
  67657. export interface _IAnimationData {
  67658. /**
  67659. * Keyframe data.
  67660. */
  67661. inputs: number[];
  67662. /**
  67663. * Value data.
  67664. */
  67665. outputs: number[][];
  67666. /**
  67667. * Animation interpolation data.
  67668. */
  67669. samplerInterpolation: AnimationSamplerInterpolation;
  67670. /**
  67671. * Minimum keyframe value.
  67672. */
  67673. inputsMin: number;
  67674. /**
  67675. * Maximum keyframe value.
  67676. */
  67677. inputsMax: number;
  67678. }
  67679. /**
  67680. * @hidden
  67681. */
  67682. export interface _IAnimationInfo {
  67683. /**
  67684. * The target channel for the animation
  67685. */
  67686. animationChannelTargetPath: AnimationChannelTargetPath;
  67687. /**
  67688. * The glTF accessor type for the data.
  67689. */
  67690. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67691. /**
  67692. * Specifies if quaternions should be used.
  67693. */
  67694. useQuaternion: boolean;
  67695. }
  67696. /**
  67697. * @hidden
  67698. * Utility class for generating glTF animation data from BabylonJS.
  67699. */
  67700. export class _GLTFAnimation {
  67701. /**
  67702. * @ignore
  67703. *
  67704. * Creates glTF channel animation from BabylonJS animation.
  67705. * @param babylonTransformNode - BabylonJS mesh.
  67706. * @param animation - animation.
  67707. * @param animationChannelTargetPath - The target animation channel.
  67708. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  67709. * @param useQuaternion - Specifies if quaternions are used.
  67710. * @returns nullable IAnimationData
  67711. */
  67712. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  67713. private static _DeduceAnimationInfo;
  67714. /**
  67715. * @ignore
  67716. * Create node animations from the transform node animations
  67717. * @param babylonNode
  67718. * @param runtimeGLTFAnimation
  67719. * @param idleGLTFAnimations
  67720. * @param nodeMap
  67721. * @param nodes
  67722. * @param binaryWriter
  67723. * @param bufferViews
  67724. * @param accessors
  67725. * @param convertToRightHandedSystem
  67726. */
  67727. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  67728. [key: number]: number;
  67729. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67730. /**
  67731. * @ignore
  67732. * Create node animations from the animation groups
  67733. * @param babylonScene
  67734. * @param glTFAnimations
  67735. * @param nodeMap
  67736. * @param nodes
  67737. * @param binaryWriter
  67738. * @param bufferViews
  67739. * @param accessors
  67740. * @param convertToRightHandedSystem
  67741. */
  67742. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67743. [key: number]: number;
  67744. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67745. private static AddAnimation;
  67746. /**
  67747. * Create a baked animation
  67748. * @param babylonTransformNode BabylonJS mesh
  67749. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67750. * @param animationChannelTargetPath animation target channel
  67751. * @param minFrame minimum animation frame
  67752. * @param maxFrame maximum animation frame
  67753. * @param fps frames per second of the animation
  67754. * @param inputs input key frames of the animation
  67755. * @param outputs output key frame data of the animation
  67756. * @param convertToRightHandedSystem converts the values to right-handed
  67757. * @param useQuaternion specifies if quaternions should be used
  67758. */
  67759. private static _CreateBakedAnimation;
  67760. private static _ConvertFactorToVector3OrQuaternion;
  67761. private static _SetInterpolatedValue;
  67762. /**
  67763. * Creates linear animation from the animation key frames
  67764. * @param babylonTransformNode BabylonJS mesh
  67765. * @param animation BabylonJS animation
  67766. * @param animationChannelTargetPath The target animation channel
  67767. * @param frameDelta The difference between the last and first frame of the animation
  67768. * @param inputs Array to store the key frame times
  67769. * @param outputs Array to store the key frame data
  67770. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67771. * @param useQuaternion Specifies if quaternions are used in the animation
  67772. */
  67773. private static _CreateLinearOrStepAnimation;
  67774. /**
  67775. * Creates cubic spline animation from the animation key frames
  67776. * @param babylonTransformNode BabylonJS mesh
  67777. * @param animation BabylonJS animation
  67778. * @param animationChannelTargetPath The target animation channel
  67779. * @param frameDelta The difference between the last and first frame of the animation
  67780. * @param inputs Array to store the key frame times
  67781. * @param outputs Array to store the key frame data
  67782. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67783. * @param useQuaternion Specifies if quaternions are used in the animation
  67784. */
  67785. private static _CreateCubicSplineAnimation;
  67786. private static _GetBasePositionRotationOrScale;
  67787. /**
  67788. * Adds a key frame value
  67789. * @param keyFrame
  67790. * @param animation
  67791. * @param outputs
  67792. * @param animationChannelTargetPath
  67793. * @param basePositionRotationOrScale
  67794. * @param convertToRightHandedSystem
  67795. * @param useQuaternion
  67796. */
  67797. private static _AddKeyframeValue;
  67798. /**
  67799. * Determine the interpolation based on the key frames
  67800. * @param keyFrames
  67801. * @param animationChannelTargetPath
  67802. * @param useQuaternion
  67803. */
  67804. private static _DeduceInterpolation;
  67805. /**
  67806. * Adds an input tangent or output tangent to the output data
  67807. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67808. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67809. * @param outputs The animation data by keyframe
  67810. * @param animationChannelTargetPath The target animation channel
  67811. * @param interpolation The interpolation type
  67812. * @param keyFrame The key frame with the animation data
  67813. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67814. * @param useQuaternion Specifies if quaternions are used
  67815. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67816. */
  67817. private static AddSplineTangent;
  67818. /**
  67819. * Get the minimum and maximum key frames' frame values
  67820. * @param keyFrames animation key frames
  67821. * @returns the minimum and maximum key frame value
  67822. */
  67823. private static calculateMinMaxKeyFrames;
  67824. }
  67825. }
  67826. declare module BABYLON.GLTF2.Exporter {
  67827. /** @hidden */
  67828. export var textureTransformPixelShader: {
  67829. name: string;
  67830. shader: string;
  67831. };
  67832. }
  67833. declare module BABYLON.GLTF2.Exporter.Extensions {
  67834. /**
  67835. * @hidden
  67836. */
  67837. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67838. /** Name of this extension */
  67839. readonly name: string;
  67840. /** Defines whether this extension is enabled */
  67841. enabled: boolean;
  67842. /** Defines whether this extension is required */
  67843. required: boolean;
  67844. /** Reference to the glTF exporter */
  67845. private _exporter;
  67846. constructor(exporter: _Exporter);
  67847. dispose(): void;
  67848. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67849. /**
  67850. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67851. * @param babylonTexture
  67852. * @param offset
  67853. * @param rotation
  67854. * @param scale
  67855. * @param scene
  67856. */
  67857. private _textureTransformTextureAsync;
  67858. }
  67859. }
  67860. declare module BABYLON.GLTF2.Exporter.Extensions {
  67861. /**
  67862. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67863. */
  67864. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67865. /** The name of this extension. */
  67866. readonly name: string;
  67867. /** Defines whether this extension is enabled. */
  67868. enabled: boolean;
  67869. /** Defines whether this extension is required */
  67870. required: boolean;
  67871. /** Reference to the glTF exporter */
  67872. private _exporter;
  67873. private _lights;
  67874. /** @hidden */
  67875. constructor(exporter: _Exporter);
  67876. /** @hidden */
  67877. dispose(): void;
  67878. /** @hidden */
  67879. onExporting(): void;
  67880. /**
  67881. * Define this method to modify the default behavior when exporting a node
  67882. * @param context The context when exporting the node
  67883. * @param node glTF node
  67884. * @param babylonNode BabylonJS node
  67885. * @returns nullable INode promise
  67886. */
  67887. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67888. }
  67889. }
  67890. declare module BABYLON {
  67891. /**
  67892. * Class for generating STL data from a Babylon scene.
  67893. */
  67894. export class STLExport {
  67895. /**
  67896. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67897. * @param meshes list defines the mesh to serialize
  67898. * @param download triggers the automatic download of the file.
  67899. * @param fileName changes the downloads fileName.
  67900. * @param binary changes the STL to a binary type.
  67901. * @param isLittleEndian toggle for binary type exporter.
  67902. * @returns the STL as UTF8 string
  67903. */
  67904. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67905. }
  67906. }
  67907. /**
  67908. * @ignoreChildren
  67909. * @ignore
  67910. */
  67911. declare module "babylonjs-gltf2interface" {
  67912. export = BABYLON.GLTF2;
  67913. }
  67914. /**
  67915. * Module for glTF 2.0 Interface
  67916. * @ignoreChildren
  67917. * @ignore
  67918. */
  67919. declare module BABYLON.GLTF2 {
  67920. /**
  67921. * The datatype of the components in the attribute
  67922. */
  67923. const enum AccessorComponentType {
  67924. /**
  67925. * Byte
  67926. */
  67927. BYTE = 5120,
  67928. /**
  67929. * Unsigned Byte
  67930. */
  67931. UNSIGNED_BYTE = 5121,
  67932. /**
  67933. * Short
  67934. */
  67935. SHORT = 5122,
  67936. /**
  67937. * Unsigned Short
  67938. */
  67939. UNSIGNED_SHORT = 5123,
  67940. /**
  67941. * Unsigned Int
  67942. */
  67943. UNSIGNED_INT = 5125,
  67944. /**
  67945. * Float
  67946. */
  67947. FLOAT = 5126,
  67948. }
  67949. /**
  67950. * Specifies if the attirbute is a scalar, vector, or matrix
  67951. */
  67952. const enum AccessorType {
  67953. /**
  67954. * Scalar
  67955. */
  67956. SCALAR = "SCALAR",
  67957. /**
  67958. * Vector2
  67959. */
  67960. VEC2 = "VEC2",
  67961. /**
  67962. * Vector3
  67963. */
  67964. VEC3 = "VEC3",
  67965. /**
  67966. * Vector4
  67967. */
  67968. VEC4 = "VEC4",
  67969. /**
  67970. * Matrix2x2
  67971. */
  67972. MAT2 = "MAT2",
  67973. /**
  67974. * Matrix3x3
  67975. */
  67976. MAT3 = "MAT3",
  67977. /**
  67978. * Matrix4x4
  67979. */
  67980. MAT4 = "MAT4",
  67981. }
  67982. /**
  67983. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67984. */
  67985. const enum AnimationChannelTargetPath {
  67986. /**
  67987. * Translation
  67988. */
  67989. TRANSLATION = "translation",
  67990. /**
  67991. * Rotation
  67992. */
  67993. ROTATION = "rotation",
  67994. /**
  67995. * Scale
  67996. */
  67997. SCALE = "scale",
  67998. /**
  67999. * Weights
  68000. */
  68001. WEIGHTS = "weights",
  68002. }
  68003. /**
  68004. * Interpolation algorithm
  68005. */
  68006. const enum AnimationSamplerInterpolation {
  68007. /**
  68008. * The animated values are linearly interpolated between keyframes
  68009. */
  68010. LINEAR = "LINEAR",
  68011. /**
  68012. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68013. */
  68014. STEP = "STEP",
  68015. /**
  68016. * The animation's interpolation is computed using a cubic spline with specified tangents
  68017. */
  68018. CUBICSPLINE = "CUBICSPLINE",
  68019. }
  68020. /**
  68021. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68022. */
  68023. const enum CameraType {
  68024. /**
  68025. * A perspective camera containing properties to create a perspective projection matrix
  68026. */
  68027. PERSPECTIVE = "perspective",
  68028. /**
  68029. * An orthographic camera containing properties to create an orthographic projection matrix
  68030. */
  68031. ORTHOGRAPHIC = "orthographic",
  68032. }
  68033. /**
  68034. * The mime-type of the image
  68035. */
  68036. const enum ImageMimeType {
  68037. /**
  68038. * JPEG Mime-type
  68039. */
  68040. JPEG = "image/jpeg",
  68041. /**
  68042. * PNG Mime-type
  68043. */
  68044. PNG = "image/png",
  68045. }
  68046. /**
  68047. * The alpha rendering mode of the material
  68048. */
  68049. const enum MaterialAlphaMode {
  68050. /**
  68051. * The alpha value is ignored and the rendered output is fully opaque
  68052. */
  68053. OPAQUE = "OPAQUE",
  68054. /**
  68055. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68056. */
  68057. MASK = "MASK",
  68058. /**
  68059. * 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)
  68060. */
  68061. BLEND = "BLEND",
  68062. }
  68063. /**
  68064. * The type of the primitives to render
  68065. */
  68066. const enum MeshPrimitiveMode {
  68067. /**
  68068. * Points
  68069. */
  68070. POINTS = 0,
  68071. /**
  68072. * Lines
  68073. */
  68074. LINES = 1,
  68075. /**
  68076. * Line Loop
  68077. */
  68078. LINE_LOOP = 2,
  68079. /**
  68080. * Line Strip
  68081. */
  68082. LINE_STRIP = 3,
  68083. /**
  68084. * Triangles
  68085. */
  68086. TRIANGLES = 4,
  68087. /**
  68088. * Triangle Strip
  68089. */
  68090. TRIANGLE_STRIP = 5,
  68091. /**
  68092. * Triangle Fan
  68093. */
  68094. TRIANGLE_FAN = 6,
  68095. }
  68096. /**
  68097. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68098. */
  68099. const enum TextureMagFilter {
  68100. /**
  68101. * Nearest
  68102. */
  68103. NEAREST = 9728,
  68104. /**
  68105. * Linear
  68106. */
  68107. LINEAR = 9729,
  68108. }
  68109. /**
  68110. * Minification filter. All valid values correspond to WebGL enums
  68111. */
  68112. const enum TextureMinFilter {
  68113. /**
  68114. * Nearest
  68115. */
  68116. NEAREST = 9728,
  68117. /**
  68118. * Linear
  68119. */
  68120. LINEAR = 9729,
  68121. /**
  68122. * Nearest Mip-Map Nearest
  68123. */
  68124. NEAREST_MIPMAP_NEAREST = 9984,
  68125. /**
  68126. * Linear Mipmap Nearest
  68127. */
  68128. LINEAR_MIPMAP_NEAREST = 9985,
  68129. /**
  68130. * Nearest Mipmap Linear
  68131. */
  68132. NEAREST_MIPMAP_LINEAR = 9986,
  68133. /**
  68134. * Linear Mipmap Linear
  68135. */
  68136. LINEAR_MIPMAP_LINEAR = 9987,
  68137. }
  68138. /**
  68139. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68140. */
  68141. const enum TextureWrapMode {
  68142. /**
  68143. * Clamp to Edge
  68144. */
  68145. CLAMP_TO_EDGE = 33071,
  68146. /**
  68147. * Mirrored Repeat
  68148. */
  68149. MIRRORED_REPEAT = 33648,
  68150. /**
  68151. * Repeat
  68152. */
  68153. REPEAT = 10497,
  68154. }
  68155. /**
  68156. * glTF Property
  68157. */
  68158. interface IProperty {
  68159. /**
  68160. * Dictionary object with extension-specific objects
  68161. */
  68162. extensions?: {
  68163. [key: string]: any;
  68164. };
  68165. /**
  68166. * Application-Specific data
  68167. */
  68168. extras?: any;
  68169. }
  68170. /**
  68171. * glTF Child of Root Property
  68172. */
  68173. interface IChildRootProperty extends IProperty {
  68174. /**
  68175. * The user-defined name of this object
  68176. */
  68177. name?: string;
  68178. }
  68179. /**
  68180. * Indices of those attributes that deviate from their initialization value
  68181. */
  68182. interface IAccessorSparseIndices extends IProperty {
  68183. /**
  68184. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68185. */
  68186. bufferView: number;
  68187. /**
  68188. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68189. */
  68190. byteOffset?: number;
  68191. /**
  68192. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68193. */
  68194. componentType: AccessorComponentType;
  68195. }
  68196. /**
  68197. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68198. */
  68199. interface IAccessorSparseValues extends IProperty {
  68200. /**
  68201. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68202. */
  68203. bufferView: number;
  68204. /**
  68205. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68206. */
  68207. byteOffset?: number;
  68208. }
  68209. /**
  68210. * Sparse storage of attributes that deviate from their initialization value
  68211. */
  68212. interface IAccessorSparse extends IProperty {
  68213. /**
  68214. * The number of attributes encoded in this sparse accessor
  68215. */
  68216. count: number;
  68217. /**
  68218. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68219. */
  68220. indices: IAccessorSparseIndices;
  68221. /**
  68222. * 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
  68223. */
  68224. values: IAccessorSparseValues;
  68225. }
  68226. /**
  68227. * 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
  68228. */
  68229. interface IAccessor extends IChildRootProperty {
  68230. /**
  68231. * The index of the bufferview
  68232. */
  68233. bufferView?: number;
  68234. /**
  68235. * The offset relative to the start of the bufferView in bytes
  68236. */
  68237. byteOffset?: number;
  68238. /**
  68239. * The datatype of components in the attribute
  68240. */
  68241. componentType: AccessorComponentType;
  68242. /**
  68243. * Specifies whether integer data values should be normalized
  68244. */
  68245. normalized?: boolean;
  68246. /**
  68247. * The number of attributes referenced by this accessor
  68248. */
  68249. count: number;
  68250. /**
  68251. * Specifies if the attribute is a scalar, vector, or matrix
  68252. */
  68253. type: AccessorType;
  68254. /**
  68255. * Maximum value of each component in this attribute
  68256. */
  68257. max?: number[];
  68258. /**
  68259. * Minimum value of each component in this attribute
  68260. */
  68261. min?: number[];
  68262. /**
  68263. * Sparse storage of attributes that deviate from their initialization value
  68264. */
  68265. sparse?: IAccessorSparse;
  68266. }
  68267. /**
  68268. * Targets an animation's sampler at a node's property
  68269. */
  68270. interface IAnimationChannel extends IProperty {
  68271. /**
  68272. * The index of a sampler in this animation used to compute the value for the target
  68273. */
  68274. sampler: number;
  68275. /**
  68276. * The index of the node and TRS property to target
  68277. */
  68278. target: IAnimationChannelTarget;
  68279. }
  68280. /**
  68281. * The index of the node and TRS property that an animation channel targets
  68282. */
  68283. interface IAnimationChannelTarget extends IProperty {
  68284. /**
  68285. * The index of the node to target
  68286. */
  68287. node: number;
  68288. /**
  68289. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68290. */
  68291. path: AnimationChannelTargetPath;
  68292. }
  68293. /**
  68294. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68295. */
  68296. interface IAnimationSampler extends IProperty {
  68297. /**
  68298. * The index of an accessor containing keyframe input values, e.g., time
  68299. */
  68300. input: number;
  68301. /**
  68302. * Interpolation algorithm
  68303. */
  68304. interpolation?: AnimationSamplerInterpolation;
  68305. /**
  68306. * The index of an accessor, containing keyframe output values
  68307. */
  68308. output: number;
  68309. }
  68310. /**
  68311. * A keyframe animation
  68312. */
  68313. interface IAnimation extends IChildRootProperty {
  68314. /**
  68315. * An array of channels, each of which targets an animation's sampler at a node's property
  68316. */
  68317. channels: IAnimationChannel[];
  68318. /**
  68319. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68320. */
  68321. samplers: IAnimationSampler[];
  68322. }
  68323. /**
  68324. * Metadata about the glTF asset
  68325. */
  68326. interface IAsset extends IChildRootProperty {
  68327. /**
  68328. * A copyright message suitable for display to credit the content creator
  68329. */
  68330. copyright?: string;
  68331. /**
  68332. * Tool that generated this glTF model. Useful for debugging
  68333. */
  68334. generator?: string;
  68335. /**
  68336. * The glTF version that this asset targets
  68337. */
  68338. version: string;
  68339. /**
  68340. * The minimum glTF version that this asset targets
  68341. */
  68342. minVersion?: string;
  68343. }
  68344. /**
  68345. * A buffer points to binary geometry, animation, or skins
  68346. */
  68347. interface IBuffer extends IChildRootProperty {
  68348. /**
  68349. * 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
  68350. */
  68351. uri?: string;
  68352. /**
  68353. * The length of the buffer in bytes
  68354. */
  68355. byteLength: number;
  68356. }
  68357. /**
  68358. * A view into a buffer generally representing a subset of the buffer
  68359. */
  68360. interface IBufferView extends IChildRootProperty {
  68361. /**
  68362. * The index of the buffer
  68363. */
  68364. buffer: number;
  68365. /**
  68366. * The offset into the buffer in bytes
  68367. */
  68368. byteOffset?: number;
  68369. /**
  68370. * The lenth of the bufferView in bytes
  68371. */
  68372. byteLength: number;
  68373. /**
  68374. * The stride, in bytes
  68375. */
  68376. byteStride?: number;
  68377. }
  68378. /**
  68379. * An orthographic camera containing properties to create an orthographic projection matrix
  68380. */
  68381. interface ICameraOrthographic extends IProperty {
  68382. /**
  68383. * The floating-point horizontal magnification of the view. Must not be zero
  68384. */
  68385. xmag: number;
  68386. /**
  68387. * The floating-point vertical magnification of the view. Must not be zero
  68388. */
  68389. ymag: number;
  68390. /**
  68391. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68392. */
  68393. zfar: number;
  68394. /**
  68395. * The floating-point distance to the near clipping plane
  68396. */
  68397. znear: number;
  68398. }
  68399. /**
  68400. * A perspective camera containing properties to create a perspective projection matrix
  68401. */
  68402. interface ICameraPerspective extends IProperty {
  68403. /**
  68404. * The floating-point aspect ratio of the field of view
  68405. */
  68406. aspectRatio?: number;
  68407. /**
  68408. * The floating-point vertical field of view in radians
  68409. */
  68410. yfov: number;
  68411. /**
  68412. * The floating-point distance to the far clipping plane
  68413. */
  68414. zfar?: number;
  68415. /**
  68416. * The floating-point distance to the near clipping plane
  68417. */
  68418. znear: number;
  68419. }
  68420. /**
  68421. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68422. */
  68423. interface ICamera extends IChildRootProperty {
  68424. /**
  68425. * An orthographic camera containing properties to create an orthographic projection matrix
  68426. */
  68427. orthographic?: ICameraOrthographic;
  68428. /**
  68429. * A perspective camera containing properties to create a perspective projection matrix
  68430. */
  68431. perspective?: ICameraPerspective;
  68432. /**
  68433. * Specifies if the camera uses a perspective or orthographic projection
  68434. */
  68435. type: CameraType;
  68436. }
  68437. /**
  68438. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68439. */
  68440. interface IImage extends IChildRootProperty {
  68441. /**
  68442. * 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
  68443. */
  68444. uri?: string;
  68445. /**
  68446. * The image's MIME type
  68447. */
  68448. mimeType?: ImageMimeType;
  68449. /**
  68450. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68451. */
  68452. bufferView?: number;
  68453. }
  68454. /**
  68455. * Material Normal Texture Info
  68456. */
  68457. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68458. /**
  68459. * The scalar multiplier applied to each normal vector of the normal texture
  68460. */
  68461. scale?: number;
  68462. }
  68463. /**
  68464. * Material Occlusion Texture Info
  68465. */
  68466. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68467. /**
  68468. * A scalar multiplier controlling the amount of occlusion applied
  68469. */
  68470. strength?: number;
  68471. }
  68472. /**
  68473. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68474. */
  68475. interface IMaterialPbrMetallicRoughness {
  68476. /**
  68477. * The material's base color factor
  68478. */
  68479. baseColorFactor?: number[];
  68480. /**
  68481. * The base color texture
  68482. */
  68483. baseColorTexture?: ITextureInfo;
  68484. /**
  68485. * The metalness of the material
  68486. */
  68487. metallicFactor?: number;
  68488. /**
  68489. * The roughness of the material
  68490. */
  68491. roughnessFactor?: number;
  68492. /**
  68493. * The metallic-roughness texture
  68494. */
  68495. metallicRoughnessTexture?: ITextureInfo;
  68496. }
  68497. /**
  68498. * The material appearance of a primitive
  68499. */
  68500. interface IMaterial extends IChildRootProperty {
  68501. /**
  68502. * 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
  68503. */
  68504. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68505. /**
  68506. * The normal map texture
  68507. */
  68508. normalTexture?: IMaterialNormalTextureInfo;
  68509. /**
  68510. * The occlusion map texture
  68511. */
  68512. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68513. /**
  68514. * The emissive map texture
  68515. */
  68516. emissiveTexture?: ITextureInfo;
  68517. /**
  68518. * 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
  68519. */
  68520. emissiveFactor?: number[];
  68521. /**
  68522. * The alpha rendering mode of the material
  68523. */
  68524. alphaMode?: MaterialAlphaMode;
  68525. /**
  68526. * The alpha cutoff value of the material
  68527. */
  68528. alphaCutoff?: number;
  68529. /**
  68530. * Specifies whether the material is double sided
  68531. */
  68532. doubleSided?: boolean;
  68533. }
  68534. /**
  68535. * Geometry to be rendered with the given material
  68536. */
  68537. interface IMeshPrimitive extends IProperty {
  68538. /**
  68539. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68540. */
  68541. attributes: {
  68542. [name: string]: number;
  68543. };
  68544. /**
  68545. * The index of the accessor that contains the indices
  68546. */
  68547. indices?: number;
  68548. /**
  68549. * The index of the material to apply to this primitive when rendering
  68550. */
  68551. material?: number;
  68552. /**
  68553. * The type of primitives to render. All valid values correspond to WebGL enums
  68554. */
  68555. mode?: MeshPrimitiveMode;
  68556. /**
  68557. * 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
  68558. */
  68559. targets?: {
  68560. [name: string]: number;
  68561. }[];
  68562. }
  68563. /**
  68564. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68565. */
  68566. interface IMesh extends IChildRootProperty {
  68567. /**
  68568. * An array of primitives, each defining geometry to be rendered with a material
  68569. */
  68570. primitives: IMeshPrimitive[];
  68571. /**
  68572. * Array of weights to be applied to the Morph Targets
  68573. */
  68574. weights?: number[];
  68575. }
  68576. /**
  68577. * A node in the node hierarchy
  68578. */
  68579. interface INode extends IChildRootProperty {
  68580. /**
  68581. * The index of the camera referenced by this node
  68582. */
  68583. camera?: number;
  68584. /**
  68585. * The indices of this node's children
  68586. */
  68587. children?: number[];
  68588. /**
  68589. * The index of the skin referenced by this node
  68590. */
  68591. skin?: number;
  68592. /**
  68593. * A floating-point 4x4 transformation matrix stored in column-major order
  68594. */
  68595. matrix?: number[];
  68596. /**
  68597. * The index of the mesh in this node
  68598. */
  68599. mesh?: number;
  68600. /**
  68601. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68602. */
  68603. rotation?: number[];
  68604. /**
  68605. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68606. */
  68607. scale?: number[];
  68608. /**
  68609. * The node's translation along the x, y, and z axes
  68610. */
  68611. translation?: number[];
  68612. /**
  68613. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68614. */
  68615. weights?: number[];
  68616. }
  68617. /**
  68618. * Texture sampler properties for filtering and wrapping modes
  68619. */
  68620. interface ISampler extends IChildRootProperty {
  68621. /**
  68622. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68623. */
  68624. magFilter?: TextureMagFilter;
  68625. /**
  68626. * Minification filter. All valid values correspond to WebGL enums
  68627. */
  68628. minFilter?: TextureMinFilter;
  68629. /**
  68630. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68631. */
  68632. wrapS?: TextureWrapMode;
  68633. /**
  68634. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68635. */
  68636. wrapT?: TextureWrapMode;
  68637. }
  68638. /**
  68639. * The root nodes of a scene
  68640. */
  68641. interface IScene extends IChildRootProperty {
  68642. /**
  68643. * The indices of each root node
  68644. */
  68645. nodes: number[];
  68646. }
  68647. /**
  68648. * Joints and matrices defining a skin
  68649. */
  68650. interface ISkin extends IChildRootProperty {
  68651. /**
  68652. * 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
  68653. */
  68654. inverseBindMatrices?: number;
  68655. /**
  68656. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68657. */
  68658. skeleton?: number;
  68659. /**
  68660. * 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)
  68661. */
  68662. joints: number[];
  68663. }
  68664. /**
  68665. * A texture and its sampler
  68666. */
  68667. interface ITexture extends IChildRootProperty {
  68668. /**
  68669. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68670. */
  68671. sampler?: number;
  68672. /**
  68673. * The index of the image used by this texture
  68674. */
  68675. source: number;
  68676. }
  68677. /**
  68678. * Reference to a texture
  68679. */
  68680. interface ITextureInfo extends IProperty {
  68681. /**
  68682. * The index of the texture
  68683. */
  68684. index: number;
  68685. /**
  68686. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68687. */
  68688. texCoord?: number;
  68689. }
  68690. /**
  68691. * The root object for a glTF asset
  68692. */
  68693. interface IGLTF extends IProperty {
  68694. /**
  68695. * An array of accessors. An accessor is a typed view into a bufferView
  68696. */
  68697. accessors?: IAccessor[];
  68698. /**
  68699. * An array of keyframe animations
  68700. */
  68701. animations?: IAnimation[];
  68702. /**
  68703. * Metadata about the glTF asset
  68704. */
  68705. asset: IAsset;
  68706. /**
  68707. * An array of buffers. A buffer points to binary geometry, animation, or skins
  68708. */
  68709. buffers?: IBuffer[];
  68710. /**
  68711. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  68712. */
  68713. bufferViews?: IBufferView[];
  68714. /**
  68715. * An array of cameras
  68716. */
  68717. cameras?: ICamera[];
  68718. /**
  68719. * Names of glTF extensions used somewhere in this asset
  68720. */
  68721. extensionsUsed?: string[];
  68722. /**
  68723. * Names of glTF extensions required to properly load this asset
  68724. */
  68725. extensionsRequired?: string[];
  68726. /**
  68727. * An array of images. An image defines data used to create a texture
  68728. */
  68729. images?: IImage[];
  68730. /**
  68731. * An array of materials. A material defines the appearance of a primitive
  68732. */
  68733. materials?: IMaterial[];
  68734. /**
  68735. * An array of meshes. A mesh is a set of primitives to be rendered
  68736. */
  68737. meshes?: IMesh[];
  68738. /**
  68739. * An array of nodes
  68740. */
  68741. nodes?: INode[];
  68742. /**
  68743. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68744. */
  68745. samplers?: ISampler[];
  68746. /**
  68747. * The index of the default scene
  68748. */
  68749. scene?: number;
  68750. /**
  68751. * An array of scenes
  68752. */
  68753. scenes?: IScene[];
  68754. /**
  68755. * An array of skins. A skin is defined by joints and matrices
  68756. */
  68757. skins?: ISkin[];
  68758. /**
  68759. * An array of textures
  68760. */
  68761. textures?: ITexture[];
  68762. }
  68763. /**
  68764. * The glTF validation results
  68765. */
  68766. interface IGLTFValidationResults {
  68767. info: {
  68768. generator: string;
  68769. hasAnimations: boolean;
  68770. hasDefaultScene: boolean;
  68771. hasMaterials: boolean;
  68772. hasMorphTargets: boolean;
  68773. hasSkins: boolean;
  68774. hasTextures: boolean;
  68775. maxAttributesUsed: number;
  68776. primitivesCount: number
  68777. };
  68778. issues: {
  68779. messages: Array<string>;
  68780. numErrors: number;
  68781. numHints: number;
  68782. numInfos: number;
  68783. numWarnings: number;
  68784. truncated: boolean
  68785. };
  68786. mimeType: string;
  68787. uri: string;
  68788. validatedAt: string;
  68789. validatorVersion: string;
  68790. }
  68791. /**
  68792. * The glTF validation options
  68793. */
  68794. interface IGLTFValidationOptions {
  68795. uri?: string;
  68796. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68797. validateAccessorData?: boolean;
  68798. maxIssues?: number;
  68799. ignoredIssues?: Array<string>;
  68800. severityOverrides?: Object;
  68801. }
  68802. /**
  68803. * The glTF validator object
  68804. */
  68805. interface IGLTFValidator {
  68806. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68807. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68808. }
  68809. }
  68810. declare module BABYLON {
  68811. /** @hidden */
  68812. export var cellPixelShader: {
  68813. name: string;
  68814. shader: string;
  68815. };
  68816. }
  68817. declare module BABYLON {
  68818. /** @hidden */
  68819. export var cellVertexShader: {
  68820. name: string;
  68821. shader: string;
  68822. };
  68823. }
  68824. declare module BABYLON {
  68825. export class CellMaterial extends BABYLON.PushMaterial {
  68826. private _diffuseTexture;
  68827. diffuseTexture: BABYLON.BaseTexture;
  68828. diffuseColor: BABYLON.Color3;
  68829. _computeHighLevel: boolean;
  68830. computeHighLevel: boolean;
  68831. private _disableLighting;
  68832. disableLighting: boolean;
  68833. private _maxSimultaneousLights;
  68834. maxSimultaneousLights: number;
  68835. private _renderId;
  68836. constructor(name: string, scene: BABYLON.Scene);
  68837. needAlphaBlending(): boolean;
  68838. needAlphaTesting(): boolean;
  68839. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68840. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68841. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68842. getAnimatables(): BABYLON.IAnimatable[];
  68843. getActiveTextures(): BABYLON.BaseTexture[];
  68844. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68845. dispose(forceDisposeEffect?: boolean): void;
  68846. getClassName(): string;
  68847. clone(name: string): CellMaterial;
  68848. serialize(): any;
  68849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68850. }
  68851. }
  68852. declare module BABYLON {
  68853. export class CustomShaderStructure {
  68854. FragmentStore: string;
  68855. VertexStore: string;
  68856. constructor();
  68857. }
  68858. export class ShaderSpecialParts {
  68859. constructor();
  68860. Fragment_Begin: string;
  68861. Fragment_Definitions: string;
  68862. Fragment_MainBegin: string;
  68863. Fragment_Custom_Diffuse: string;
  68864. Fragment_Before_Lights: string;
  68865. Fragment_Before_Fog: string;
  68866. Fragment_Custom_Alpha: string;
  68867. Fragment_Before_FragColor: string;
  68868. Vertex_Begin: string;
  68869. Vertex_Definitions: string;
  68870. Vertex_MainBegin: string;
  68871. Vertex_Before_PositionUpdated: string;
  68872. Vertex_Before_NormalUpdated: string;
  68873. Vertex_MainEnd: string;
  68874. }
  68875. export class CustomMaterial extends BABYLON.StandardMaterial {
  68876. static ShaderIndexer: number;
  68877. CustomParts: ShaderSpecialParts;
  68878. _isCreatedShader: boolean;
  68879. _createdShaderName: string;
  68880. _customUniform: string[];
  68881. _newUniforms: string[];
  68882. _newUniformInstances: any[];
  68883. _newSamplerInstances: BABYLON.Texture[];
  68884. FragmentShader: string;
  68885. VertexShader: string;
  68886. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68887. ReviewUniform(name: string, arr: string[]): string[];
  68888. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68889. constructor(name: string, scene: BABYLON.Scene);
  68890. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68891. Fragment_Begin(shaderPart: string): CustomMaterial;
  68892. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68893. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68894. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68895. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68896. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68897. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68898. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68899. Vertex_Begin(shaderPart: string): CustomMaterial;
  68900. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68901. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68902. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68903. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68904. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68905. }
  68906. }
  68907. declare module BABYLON {
  68908. export class ShaderAlebdoParts {
  68909. constructor();
  68910. Fragment_Begin: string;
  68911. Fragment_Definitions: string;
  68912. Fragment_MainBegin: string;
  68913. Fragment_Custom_Albedo: string;
  68914. Fragment_Before_Lights: string;
  68915. Fragment_Custom_MetallicRoughness: string;
  68916. Fragment_Custom_MicroSurface: string;
  68917. Fragment_Before_Fog: string;
  68918. Fragment_Custom_Alpha: string;
  68919. Fragment_Before_FragColor: string;
  68920. Vertex_Begin: string;
  68921. Vertex_Definitions: string;
  68922. Vertex_MainBegin: string;
  68923. Vertex_Before_PositionUpdated: string;
  68924. Vertex_Before_NormalUpdated: string;
  68925. Vertex_MainEnd: string;
  68926. }
  68927. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68928. static ShaderIndexer: number;
  68929. CustomParts: ShaderAlebdoParts;
  68930. _isCreatedShader: boolean;
  68931. _createdShaderName: string;
  68932. _customUniform: string[];
  68933. _newUniforms: string[];
  68934. _newUniformInstances: any[];
  68935. _newSamplerInstances: BABYLON.Texture[];
  68936. FragmentShader: string;
  68937. VertexShader: string;
  68938. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68939. ReviewUniform(name: string, arr: string[]): string[];
  68940. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68941. constructor(name: string, scene: BABYLON.Scene);
  68942. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68943. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68944. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68945. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68946. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68947. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68948. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68949. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68950. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68951. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68952. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68953. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68954. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68955. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68956. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68957. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68958. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68959. }
  68960. }
  68961. declare module BABYLON {
  68962. /** @hidden */
  68963. export var firePixelShader: {
  68964. name: string;
  68965. shader: string;
  68966. };
  68967. }
  68968. declare module BABYLON {
  68969. /** @hidden */
  68970. export var fireVertexShader: {
  68971. name: string;
  68972. shader: string;
  68973. };
  68974. }
  68975. declare module BABYLON {
  68976. export class FireMaterial extends BABYLON.PushMaterial {
  68977. private _diffuseTexture;
  68978. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68979. private _distortionTexture;
  68980. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68981. private _opacityTexture;
  68982. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68983. diffuseColor: BABYLON.Color3;
  68984. speed: number;
  68985. private _scaledDiffuse;
  68986. private _renderId;
  68987. private _lastTime;
  68988. constructor(name: string, scene: BABYLON.Scene);
  68989. needAlphaBlending(): boolean;
  68990. needAlphaTesting(): boolean;
  68991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68992. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68993. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68994. getAnimatables(): BABYLON.IAnimatable[];
  68995. getActiveTextures(): BABYLON.BaseTexture[];
  68996. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68997. getClassName(): string;
  68998. dispose(forceDisposeEffect?: boolean): void;
  68999. clone(name: string): FireMaterial;
  69000. serialize(): any;
  69001. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69002. }
  69003. }
  69004. declare module BABYLON {
  69005. /** @hidden */
  69006. export var furPixelShader: {
  69007. name: string;
  69008. shader: string;
  69009. };
  69010. }
  69011. declare module BABYLON {
  69012. /** @hidden */
  69013. export var furVertexShader: {
  69014. name: string;
  69015. shader: string;
  69016. };
  69017. }
  69018. declare module BABYLON {
  69019. export class FurMaterial extends BABYLON.PushMaterial {
  69020. private _diffuseTexture;
  69021. diffuseTexture: BABYLON.BaseTexture;
  69022. private _heightTexture;
  69023. heightTexture: BABYLON.BaseTexture;
  69024. diffuseColor: BABYLON.Color3;
  69025. furLength: number;
  69026. furAngle: number;
  69027. furColor: BABYLON.Color3;
  69028. furOffset: number;
  69029. furSpacing: number;
  69030. furGravity: BABYLON.Vector3;
  69031. furSpeed: number;
  69032. furDensity: number;
  69033. furOcclusion: number;
  69034. furTexture: BABYLON.DynamicTexture;
  69035. private _disableLighting;
  69036. disableLighting: boolean;
  69037. private _maxSimultaneousLights;
  69038. maxSimultaneousLights: number;
  69039. highLevelFur: boolean;
  69040. _meshes: BABYLON.AbstractMesh[];
  69041. private _renderId;
  69042. private _furTime;
  69043. constructor(name: string, scene: BABYLON.Scene);
  69044. furTime: number;
  69045. needAlphaBlending(): boolean;
  69046. needAlphaTesting(): boolean;
  69047. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69048. updateFur(): void;
  69049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69051. getAnimatables(): BABYLON.IAnimatable[];
  69052. getActiveTextures(): BABYLON.BaseTexture[];
  69053. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69054. dispose(forceDisposeEffect?: boolean): void;
  69055. clone(name: string): FurMaterial;
  69056. serialize(): any;
  69057. getClassName(): string;
  69058. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69059. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69060. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69061. }
  69062. }
  69063. declare module BABYLON {
  69064. /** @hidden */
  69065. export var gradientPixelShader: {
  69066. name: string;
  69067. shader: string;
  69068. };
  69069. }
  69070. declare module BABYLON {
  69071. /** @hidden */
  69072. export var gradientVertexShader: {
  69073. name: string;
  69074. shader: string;
  69075. };
  69076. }
  69077. declare module BABYLON {
  69078. export class GradientMaterial extends BABYLON.PushMaterial {
  69079. private _maxSimultaneousLights;
  69080. maxSimultaneousLights: number;
  69081. topColor: BABYLON.Color3;
  69082. topColorAlpha: number;
  69083. bottomColor: BABYLON.Color3;
  69084. bottomColorAlpha: number;
  69085. offset: number;
  69086. scale: number;
  69087. smoothness: number;
  69088. private _disableLighting;
  69089. disableLighting: boolean;
  69090. private _renderId;
  69091. constructor(name: string, scene: BABYLON.Scene);
  69092. needAlphaBlending(): boolean;
  69093. needAlphaTesting(): boolean;
  69094. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69095. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69096. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69097. getAnimatables(): BABYLON.IAnimatable[];
  69098. dispose(forceDisposeEffect?: boolean): void;
  69099. clone(name: string): GradientMaterial;
  69100. serialize(): any;
  69101. getClassName(): string;
  69102. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69103. }
  69104. }
  69105. declare module BABYLON {
  69106. /** @hidden */
  69107. export var gridPixelShader: {
  69108. name: string;
  69109. shader: string;
  69110. };
  69111. }
  69112. declare module BABYLON {
  69113. /** @hidden */
  69114. export var gridVertexShader: {
  69115. name: string;
  69116. shader: string;
  69117. };
  69118. }
  69119. declare module BABYLON {
  69120. /**
  69121. * The grid materials allows you to wrap any shape with a grid.
  69122. * Colors are customizable.
  69123. */
  69124. export class GridMaterial extends BABYLON.PushMaterial {
  69125. /**
  69126. * Main color of the grid (e.g. between lines)
  69127. */
  69128. mainColor: BABYLON.Color3;
  69129. /**
  69130. * Color of the grid lines.
  69131. */
  69132. lineColor: BABYLON.Color3;
  69133. /**
  69134. * The scale of the grid compared to unit.
  69135. */
  69136. gridRatio: number;
  69137. /**
  69138. * Allows setting an offset for the grid lines.
  69139. */
  69140. gridOffset: BABYLON.Vector3;
  69141. /**
  69142. * The frequency of thicker lines.
  69143. */
  69144. majorUnitFrequency: number;
  69145. /**
  69146. * The visibility of minor units in the grid.
  69147. */
  69148. minorUnitVisibility: number;
  69149. /**
  69150. * The grid opacity outside of the lines.
  69151. */
  69152. opacity: number;
  69153. /**
  69154. * Determine RBG output is premultiplied by alpha value.
  69155. */
  69156. preMultiplyAlpha: boolean;
  69157. private _opacityTexture;
  69158. opacityTexture: BABYLON.BaseTexture;
  69159. private _gridControl;
  69160. private _renderId;
  69161. /**
  69162. * constructor
  69163. * @param name The name given to the material in order to identify it afterwards.
  69164. * @param scene The scene the material is used in.
  69165. */
  69166. constructor(name: string, scene: BABYLON.Scene);
  69167. /**
  69168. * Returns wehter or not the grid requires alpha blending.
  69169. */
  69170. needAlphaBlending(): boolean;
  69171. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69172. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69173. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69174. /**
  69175. * Dispose the material and its associated resources.
  69176. * @param forceDisposeEffect will also dispose the used effect when true
  69177. */
  69178. dispose(forceDisposeEffect?: boolean): void;
  69179. clone(name: string): GridMaterial;
  69180. serialize(): any;
  69181. getClassName(): string;
  69182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69183. }
  69184. }
  69185. declare module BABYLON {
  69186. /** @hidden */
  69187. export var lavaPixelShader: {
  69188. name: string;
  69189. shader: string;
  69190. };
  69191. }
  69192. declare module BABYLON {
  69193. /** @hidden */
  69194. export var lavaVertexShader: {
  69195. name: string;
  69196. shader: string;
  69197. };
  69198. }
  69199. declare module BABYLON {
  69200. export class LavaMaterial extends BABYLON.PushMaterial {
  69201. private _diffuseTexture;
  69202. diffuseTexture: BABYLON.BaseTexture;
  69203. noiseTexture: BABYLON.BaseTexture;
  69204. fogColor: BABYLON.Color3;
  69205. speed: number;
  69206. movingSpeed: number;
  69207. lowFrequencySpeed: number;
  69208. fogDensity: number;
  69209. private _lastTime;
  69210. diffuseColor: BABYLON.Color3;
  69211. private _disableLighting;
  69212. disableLighting: boolean;
  69213. private _unlit;
  69214. unlit: boolean;
  69215. private _maxSimultaneousLights;
  69216. maxSimultaneousLights: number;
  69217. private _scaledDiffuse;
  69218. private _renderId;
  69219. constructor(name: string, scene: BABYLON.Scene);
  69220. needAlphaBlending(): boolean;
  69221. needAlphaTesting(): boolean;
  69222. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69223. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69225. getAnimatables(): BABYLON.IAnimatable[];
  69226. getActiveTextures(): BABYLON.BaseTexture[];
  69227. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69228. dispose(forceDisposeEffect?: boolean): void;
  69229. clone(name: string): LavaMaterial;
  69230. serialize(): any;
  69231. getClassName(): string;
  69232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69233. }
  69234. }
  69235. declare module BABYLON {
  69236. /** @hidden */
  69237. export var mixPixelShader: {
  69238. name: string;
  69239. shader: string;
  69240. };
  69241. }
  69242. declare module BABYLON {
  69243. /** @hidden */
  69244. export var mixVertexShader: {
  69245. name: string;
  69246. shader: string;
  69247. };
  69248. }
  69249. declare module BABYLON {
  69250. export class MixMaterial extends BABYLON.PushMaterial {
  69251. /**
  69252. * Mix textures
  69253. */
  69254. private _mixTexture1;
  69255. mixTexture1: BABYLON.BaseTexture;
  69256. private _mixTexture2;
  69257. mixTexture2: BABYLON.BaseTexture;
  69258. /**
  69259. * Diffuse textures
  69260. */
  69261. private _diffuseTexture1;
  69262. diffuseTexture1: BABYLON.Texture;
  69263. private _diffuseTexture2;
  69264. diffuseTexture2: BABYLON.Texture;
  69265. private _diffuseTexture3;
  69266. diffuseTexture3: BABYLON.Texture;
  69267. private _diffuseTexture4;
  69268. diffuseTexture4: BABYLON.Texture;
  69269. private _diffuseTexture5;
  69270. diffuseTexture5: BABYLON.Texture;
  69271. private _diffuseTexture6;
  69272. diffuseTexture6: BABYLON.Texture;
  69273. private _diffuseTexture7;
  69274. diffuseTexture7: BABYLON.Texture;
  69275. private _diffuseTexture8;
  69276. diffuseTexture8: BABYLON.Texture;
  69277. /**
  69278. * Uniforms
  69279. */
  69280. diffuseColor: BABYLON.Color3;
  69281. specularColor: BABYLON.Color3;
  69282. specularPower: number;
  69283. private _disableLighting;
  69284. disableLighting: boolean;
  69285. private _maxSimultaneousLights;
  69286. maxSimultaneousLights: number;
  69287. private _renderId;
  69288. constructor(name: string, scene: BABYLON.Scene);
  69289. needAlphaBlending(): boolean;
  69290. needAlphaTesting(): boolean;
  69291. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69292. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69293. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69294. getAnimatables(): BABYLON.IAnimatable[];
  69295. getActiveTextures(): BABYLON.BaseTexture[];
  69296. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69297. dispose(forceDisposeEffect?: boolean): void;
  69298. clone(name: string): MixMaterial;
  69299. serialize(): any;
  69300. getClassName(): string;
  69301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69302. }
  69303. }
  69304. declare module BABYLON {
  69305. /** @hidden */
  69306. export var normalPixelShader: {
  69307. name: string;
  69308. shader: string;
  69309. };
  69310. }
  69311. declare module BABYLON {
  69312. /** @hidden */
  69313. export var normalVertexShader: {
  69314. name: string;
  69315. shader: string;
  69316. };
  69317. }
  69318. declare module BABYLON {
  69319. export class NormalMaterial extends BABYLON.PushMaterial {
  69320. private _diffuseTexture;
  69321. diffuseTexture: BABYLON.BaseTexture;
  69322. diffuseColor: BABYLON.Color3;
  69323. private _disableLighting;
  69324. disableLighting: boolean;
  69325. private _maxSimultaneousLights;
  69326. maxSimultaneousLights: number;
  69327. private _renderId;
  69328. constructor(name: string, scene: BABYLON.Scene);
  69329. needAlphaBlending(): boolean;
  69330. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69331. needAlphaTesting(): boolean;
  69332. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69333. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69334. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69335. getAnimatables(): BABYLON.IAnimatable[];
  69336. getActiveTextures(): BABYLON.BaseTexture[];
  69337. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69338. dispose(forceDisposeEffect?: boolean): void;
  69339. clone(name: string): NormalMaterial;
  69340. serialize(): any;
  69341. getClassName(): string;
  69342. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69343. }
  69344. }
  69345. declare module BABYLON {
  69346. /** @hidden */
  69347. export var shadowOnlyPixelShader: {
  69348. name: string;
  69349. shader: string;
  69350. };
  69351. }
  69352. declare module BABYLON {
  69353. /** @hidden */
  69354. export var shadowOnlyVertexShader: {
  69355. name: string;
  69356. shader: string;
  69357. };
  69358. }
  69359. declare module BABYLON {
  69360. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69361. private _renderId;
  69362. private _activeLight;
  69363. constructor(name: string, scene: BABYLON.Scene);
  69364. shadowColor: BABYLON.Color3;
  69365. needAlphaBlending(): boolean;
  69366. needAlphaTesting(): boolean;
  69367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69368. activeLight: BABYLON.IShadowLight;
  69369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69371. clone(name: string): ShadowOnlyMaterial;
  69372. serialize(): any;
  69373. getClassName(): string;
  69374. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69375. }
  69376. }
  69377. declare module BABYLON {
  69378. /** @hidden */
  69379. export var simplePixelShader: {
  69380. name: string;
  69381. shader: string;
  69382. };
  69383. }
  69384. declare module BABYLON {
  69385. /** @hidden */
  69386. export var simpleVertexShader: {
  69387. name: string;
  69388. shader: string;
  69389. };
  69390. }
  69391. declare module BABYLON {
  69392. export class SimpleMaterial extends BABYLON.PushMaterial {
  69393. private _diffuseTexture;
  69394. diffuseTexture: BABYLON.BaseTexture;
  69395. diffuseColor: BABYLON.Color3;
  69396. private _disableLighting;
  69397. disableLighting: boolean;
  69398. private _maxSimultaneousLights;
  69399. maxSimultaneousLights: number;
  69400. private _renderId;
  69401. constructor(name: string, scene: BABYLON.Scene);
  69402. needAlphaBlending(): boolean;
  69403. needAlphaTesting(): boolean;
  69404. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69405. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69406. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69407. getAnimatables(): BABYLON.IAnimatable[];
  69408. getActiveTextures(): BABYLON.BaseTexture[];
  69409. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69410. dispose(forceDisposeEffect?: boolean): void;
  69411. clone(name: string): SimpleMaterial;
  69412. serialize(): any;
  69413. getClassName(): string;
  69414. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69415. }
  69416. }
  69417. declare module BABYLON {
  69418. /** @hidden */
  69419. export var skyPixelShader: {
  69420. name: string;
  69421. shader: string;
  69422. };
  69423. }
  69424. declare module BABYLON {
  69425. /** @hidden */
  69426. export var skyVertexShader: {
  69427. name: string;
  69428. shader: string;
  69429. };
  69430. }
  69431. declare module BABYLON {
  69432. /**
  69433. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69434. * @see https://doc.babylonjs.com/extensions/sky
  69435. */
  69436. export class SkyMaterial extends BABYLON.PushMaterial {
  69437. /**
  69438. * Defines the overall luminance of sky in interval ]0, 1[.
  69439. */
  69440. luminance: number;
  69441. /**
  69442. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69443. */
  69444. turbidity: number;
  69445. /**
  69446. * Defines the sky appearance (light intensity).
  69447. */
  69448. rayleigh: number;
  69449. /**
  69450. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69451. */
  69452. mieCoefficient: number;
  69453. /**
  69454. * Defines the amount of haze particles following the Mie scattering theory.
  69455. */
  69456. mieDirectionalG: number;
  69457. /**
  69458. * Defines the distance of the sun according to the active scene camera.
  69459. */
  69460. distance: number;
  69461. /**
  69462. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69463. * "inclined".
  69464. */
  69465. inclination: number;
  69466. /**
  69467. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69468. * an object direction and a reference direction.
  69469. */
  69470. azimuth: number;
  69471. /**
  69472. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69473. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69474. */
  69475. sunPosition: BABYLON.Vector3;
  69476. /**
  69477. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69478. * .sunPosition property.
  69479. */
  69480. useSunPosition: boolean;
  69481. /**
  69482. * Defines an offset vector used to get a horizon offset.
  69483. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69484. */
  69485. cameraOffset: BABYLON.Vector3;
  69486. private _cameraPosition;
  69487. private _renderId;
  69488. /**
  69489. * Instantiates a new sky material.
  69490. * This material allows to create dynamic and texture free
  69491. * effects for skyboxes by taking care of the atmosphere state.
  69492. * @see https://doc.babylonjs.com/extensions/sky
  69493. * @param name Define the name of the material in the scene
  69494. * @param scene Define the scene the material belong to
  69495. */
  69496. constructor(name: string, scene: BABYLON.Scene);
  69497. /**
  69498. * Specifies if the material will require alpha blending
  69499. * @returns a boolean specifying if alpha blending is needed
  69500. */
  69501. needAlphaBlending(): boolean;
  69502. /**
  69503. * Specifies if this material should be rendered in alpha test mode
  69504. * @returns false as the sky material doesn't need alpha testing.
  69505. */
  69506. needAlphaTesting(): boolean;
  69507. /**
  69508. * Get the texture used for alpha test purpose.
  69509. * @returns null as the sky material has no texture.
  69510. */
  69511. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69512. /**
  69513. * Get if the submesh is ready to be used and all its information available.
  69514. * Child classes can use it to update shaders
  69515. * @param mesh defines the mesh to check
  69516. * @param subMesh defines which submesh to check
  69517. * @param useInstances specifies that instances should be used
  69518. * @returns a boolean indicating that the submesh is ready or not
  69519. */
  69520. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69521. /**
  69522. * Binds the submesh to this material by preparing the effect and shader to draw
  69523. * @param world defines the world transformation matrix
  69524. * @param mesh defines the mesh containing the submesh
  69525. * @param subMesh defines the submesh to bind the material to
  69526. */
  69527. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69528. /**
  69529. * Get the list of animatables in the material.
  69530. * @returns the list of animatables object used in the material
  69531. */
  69532. getAnimatables(): BABYLON.IAnimatable[];
  69533. /**
  69534. * Disposes the material
  69535. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69536. */
  69537. dispose(forceDisposeEffect?: boolean): void;
  69538. /**
  69539. * Makes a duplicate of the material, and gives it a new name
  69540. * @param name defines the new name for the duplicated material
  69541. * @returns the cloned material
  69542. */
  69543. clone(name: string): SkyMaterial;
  69544. /**
  69545. * Serializes this material in a JSON representation
  69546. * @returns the serialized material object
  69547. */
  69548. serialize(): any;
  69549. /**
  69550. * Gets the current class name of the material e.g. "SkyMaterial"
  69551. * Mainly use in serialization.
  69552. * @returns the class name
  69553. */
  69554. getClassName(): string;
  69555. /**
  69556. * Creates a sky material from parsed material data
  69557. * @param source defines the JSON representation of the material
  69558. * @param scene defines the hosting scene
  69559. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69560. * @returns a new sky material
  69561. */
  69562. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69563. }
  69564. }
  69565. declare module BABYLON {
  69566. /** @hidden */
  69567. export var terrainPixelShader: {
  69568. name: string;
  69569. shader: string;
  69570. };
  69571. }
  69572. declare module BABYLON {
  69573. /** @hidden */
  69574. export var terrainVertexShader: {
  69575. name: string;
  69576. shader: string;
  69577. };
  69578. }
  69579. declare module BABYLON {
  69580. export class TerrainMaterial extends BABYLON.PushMaterial {
  69581. private _mixTexture;
  69582. mixTexture: BABYLON.BaseTexture;
  69583. private _diffuseTexture1;
  69584. diffuseTexture1: BABYLON.Texture;
  69585. private _diffuseTexture2;
  69586. diffuseTexture2: BABYLON.Texture;
  69587. private _diffuseTexture3;
  69588. diffuseTexture3: BABYLON.Texture;
  69589. private _bumpTexture1;
  69590. bumpTexture1: BABYLON.Texture;
  69591. private _bumpTexture2;
  69592. bumpTexture2: BABYLON.Texture;
  69593. private _bumpTexture3;
  69594. bumpTexture3: BABYLON.Texture;
  69595. diffuseColor: BABYLON.Color3;
  69596. specularColor: BABYLON.Color3;
  69597. specularPower: number;
  69598. private _disableLighting;
  69599. disableLighting: boolean;
  69600. private _maxSimultaneousLights;
  69601. maxSimultaneousLights: number;
  69602. private _renderId;
  69603. constructor(name: string, scene: BABYLON.Scene);
  69604. needAlphaBlending(): boolean;
  69605. needAlphaTesting(): boolean;
  69606. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69608. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69609. getAnimatables(): BABYLON.IAnimatable[];
  69610. getActiveTextures(): BABYLON.BaseTexture[];
  69611. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69612. dispose(forceDisposeEffect?: boolean): void;
  69613. clone(name: string): TerrainMaterial;
  69614. serialize(): any;
  69615. getClassName(): string;
  69616. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69617. }
  69618. }
  69619. declare module BABYLON {
  69620. /** @hidden */
  69621. export var triplanarPixelShader: {
  69622. name: string;
  69623. shader: string;
  69624. };
  69625. }
  69626. declare module BABYLON {
  69627. /** @hidden */
  69628. export var triplanarVertexShader: {
  69629. name: string;
  69630. shader: string;
  69631. };
  69632. }
  69633. declare module BABYLON {
  69634. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69635. mixTexture: BABYLON.BaseTexture;
  69636. private _diffuseTextureX;
  69637. diffuseTextureX: BABYLON.BaseTexture;
  69638. private _diffuseTextureY;
  69639. diffuseTextureY: BABYLON.BaseTexture;
  69640. private _diffuseTextureZ;
  69641. diffuseTextureZ: BABYLON.BaseTexture;
  69642. private _normalTextureX;
  69643. normalTextureX: BABYLON.BaseTexture;
  69644. private _normalTextureY;
  69645. normalTextureY: BABYLON.BaseTexture;
  69646. private _normalTextureZ;
  69647. normalTextureZ: BABYLON.BaseTexture;
  69648. tileSize: number;
  69649. diffuseColor: BABYLON.Color3;
  69650. specularColor: BABYLON.Color3;
  69651. specularPower: number;
  69652. private _disableLighting;
  69653. disableLighting: boolean;
  69654. private _maxSimultaneousLights;
  69655. maxSimultaneousLights: number;
  69656. private _renderId;
  69657. constructor(name: string, scene: BABYLON.Scene);
  69658. needAlphaBlending(): boolean;
  69659. needAlphaTesting(): boolean;
  69660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69663. getAnimatables(): BABYLON.IAnimatable[];
  69664. getActiveTextures(): BABYLON.BaseTexture[];
  69665. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69666. dispose(forceDisposeEffect?: boolean): void;
  69667. clone(name: string): TriPlanarMaterial;
  69668. serialize(): any;
  69669. getClassName(): string;
  69670. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69671. }
  69672. }
  69673. declare module BABYLON {
  69674. /** @hidden */
  69675. export var waterPixelShader: {
  69676. name: string;
  69677. shader: string;
  69678. };
  69679. }
  69680. declare module BABYLON {
  69681. /** @hidden */
  69682. export var waterVertexShader: {
  69683. name: string;
  69684. shader: string;
  69685. };
  69686. }
  69687. declare module BABYLON {
  69688. export class WaterMaterial extends BABYLON.PushMaterial {
  69689. renderTargetSize: BABYLON.Vector2;
  69690. private _bumpTexture;
  69691. bumpTexture: BABYLON.BaseTexture;
  69692. diffuseColor: BABYLON.Color3;
  69693. specularColor: BABYLON.Color3;
  69694. specularPower: number;
  69695. private _disableLighting;
  69696. disableLighting: boolean;
  69697. private _maxSimultaneousLights;
  69698. maxSimultaneousLights: number;
  69699. /**
  69700. * @param {number}: Represents the wind force
  69701. */
  69702. windForce: number;
  69703. /**
  69704. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  69705. */
  69706. windDirection: BABYLON.Vector2;
  69707. /**
  69708. * @param {number}: Wave height, represents the height of the waves
  69709. */
  69710. waveHeight: number;
  69711. /**
  69712. * @param {number}: Bump height, represents the bump height related to the bump map
  69713. */
  69714. bumpHeight: number;
  69715. /**
  69716. * @param {boolean}: Add a smaller moving bump to less steady waves.
  69717. */
  69718. private _bumpSuperimpose;
  69719. bumpSuperimpose: boolean;
  69720. /**
  69721. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  69722. */
  69723. private _fresnelSeparate;
  69724. fresnelSeparate: boolean;
  69725. /**
  69726. * @param {boolean}: bump Waves modify the reflection.
  69727. */
  69728. private _bumpAffectsReflection;
  69729. bumpAffectsReflection: boolean;
  69730. /**
  69731. * @param {number}: The water color blended with the refraction (near)
  69732. */
  69733. waterColor: BABYLON.Color3;
  69734. /**
  69735. * @param {number}: The blend factor related to the water color
  69736. */
  69737. colorBlendFactor: number;
  69738. /**
  69739. * @param {number}: The water color blended with the reflection (far)
  69740. */
  69741. waterColor2: BABYLON.Color3;
  69742. /**
  69743. * @param {number}: The blend factor related to the water color (reflection, far)
  69744. */
  69745. colorBlendFactor2: number;
  69746. /**
  69747. * @param {number}: Represents the maximum length of a wave
  69748. */
  69749. waveLength: number;
  69750. /**
  69751. * @param {number}: Defines the waves speed
  69752. */
  69753. waveSpeed: number;
  69754. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69755. private _mesh;
  69756. private _refractionRTT;
  69757. private _reflectionRTT;
  69758. private _reflectionTransform;
  69759. private _lastTime;
  69760. private _lastDeltaTime;
  69761. private _renderId;
  69762. private _useLogarithmicDepth;
  69763. private _waitingRenderList;
  69764. /**
  69765. * Gets a boolean indicating that current material needs to register RTT
  69766. */
  69767. readonly hasRenderTargetTextures: boolean;
  69768. /**
  69769. * Constructor
  69770. */
  69771. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69772. useLogarithmicDepth: boolean;
  69773. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69774. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69775. addToRenderList(node: any): void;
  69776. enableRenderTargets(enable: boolean): void;
  69777. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69778. readonly renderTargetsEnabled: boolean;
  69779. needAlphaBlending(): boolean;
  69780. needAlphaTesting(): boolean;
  69781. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69782. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69783. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69784. private _createRenderTargets;
  69785. getAnimatables(): BABYLON.IAnimatable[];
  69786. getActiveTextures(): BABYLON.BaseTexture[];
  69787. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69788. dispose(forceDisposeEffect?: boolean): void;
  69789. clone(name: string): WaterMaterial;
  69790. serialize(): any;
  69791. getClassName(): string;
  69792. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69793. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69794. }
  69795. }
  69796. declare module BABYLON {
  69797. /** @hidden */
  69798. export var asciiartPixelShader: {
  69799. name: string;
  69800. shader: string;
  69801. };
  69802. }
  69803. declare module BABYLON {
  69804. /**
  69805. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69806. *
  69807. * It basically takes care rendering the font front the given font size to a texture.
  69808. * This is used later on in the postprocess.
  69809. */
  69810. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69811. private _font;
  69812. private _text;
  69813. private _charSize;
  69814. /**
  69815. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69816. */
  69817. readonly charSize: number;
  69818. /**
  69819. * Create a new instance of the Ascii Art FontTexture class
  69820. * @param name the name of the texture
  69821. * @param font the font to use, use the W3C CSS notation
  69822. * @param text the caracter set to use in the rendering.
  69823. * @param scene the scene that owns the texture
  69824. */
  69825. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69826. /**
  69827. * Gets the max char width of a font.
  69828. * @param font the font to use, use the W3C CSS notation
  69829. * @return the max char width
  69830. */
  69831. private getFontWidth;
  69832. /**
  69833. * Gets the max char height of a font.
  69834. * @param font the font to use, use the W3C CSS notation
  69835. * @return the max char height
  69836. */
  69837. private getFontHeight;
  69838. /**
  69839. * Clones the current AsciiArtTexture.
  69840. * @return the clone of the texture.
  69841. */
  69842. clone(): AsciiArtFontTexture;
  69843. /**
  69844. * Parses a json object representing the texture and returns an instance of it.
  69845. * @param source the source JSON representation
  69846. * @param scene the scene to create the texture for
  69847. * @return the parsed texture
  69848. */
  69849. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69850. }
  69851. /**
  69852. * Option available in the Ascii Art Post Process.
  69853. */
  69854. export interface IAsciiArtPostProcessOptions {
  69855. /**
  69856. * The font to use following the w3c font definition.
  69857. */
  69858. font?: string;
  69859. /**
  69860. * The character set to use in the postprocess.
  69861. */
  69862. characterSet?: string;
  69863. /**
  69864. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69865. * This number is defined between 0 and 1;
  69866. */
  69867. mixToTile?: number;
  69868. /**
  69869. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69870. * This number is defined between 0 and 1;
  69871. */
  69872. mixToNormal?: number;
  69873. }
  69874. /**
  69875. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69876. *
  69877. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69878. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69879. */
  69880. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69881. /**
  69882. * The font texture used to render the char in the post process.
  69883. */
  69884. private _asciiArtFontTexture;
  69885. /**
  69886. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69887. * This number is defined between 0 and 1;
  69888. */
  69889. mixToTile: number;
  69890. /**
  69891. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69892. * This number is defined between 0 and 1;
  69893. */
  69894. mixToNormal: number;
  69895. /**
  69896. * Instantiates a new Ascii Art Post Process.
  69897. * @param name the name to give to the postprocess
  69898. * @camera the camera to apply the post process to.
  69899. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69900. */
  69901. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /** @hidden */
  69906. export var digitalrainPixelShader: {
  69907. name: string;
  69908. shader: string;
  69909. };
  69910. }
  69911. declare module BABYLON {
  69912. /**
  69913. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69914. *
  69915. * It basically takes care rendering the font front the given font size to a texture.
  69916. * This is used later on in the postprocess.
  69917. */
  69918. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69919. private _font;
  69920. private _text;
  69921. private _charSize;
  69922. /**
  69923. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69924. */
  69925. readonly charSize: number;
  69926. /**
  69927. * Create a new instance of the Digital Rain FontTexture class
  69928. * @param name the name of the texture
  69929. * @param font the font to use, use the W3C CSS notation
  69930. * @param text the caracter set to use in the rendering.
  69931. * @param scene the scene that owns the texture
  69932. */
  69933. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69934. /**
  69935. * Gets the max char width of a font.
  69936. * @param font the font to use, use the W3C CSS notation
  69937. * @return the max char width
  69938. */
  69939. private getFontWidth;
  69940. /**
  69941. * Gets the max char height of a font.
  69942. * @param font the font to use, use the W3C CSS notation
  69943. * @return the max char height
  69944. */
  69945. private getFontHeight;
  69946. /**
  69947. * Clones the current DigitalRainFontTexture.
  69948. * @return the clone of the texture.
  69949. */
  69950. clone(): DigitalRainFontTexture;
  69951. /**
  69952. * Parses a json object representing the texture and returns an instance of it.
  69953. * @param source the source JSON representation
  69954. * @param scene the scene to create the texture for
  69955. * @return the parsed texture
  69956. */
  69957. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69958. }
  69959. /**
  69960. * Option available in the Digital Rain Post Process.
  69961. */
  69962. export interface IDigitalRainPostProcessOptions {
  69963. /**
  69964. * The font to use following the w3c font definition.
  69965. */
  69966. font?: string;
  69967. /**
  69968. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69969. * This number is defined between 0 and 1;
  69970. */
  69971. mixToTile?: number;
  69972. /**
  69973. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69974. * This number is defined between 0 and 1;
  69975. */
  69976. mixToNormal?: number;
  69977. }
  69978. /**
  69979. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69980. *
  69981. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69982. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69983. */
  69984. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69985. /**
  69986. * The font texture used to render the char in the post process.
  69987. */
  69988. private _digitalRainFontTexture;
  69989. /**
  69990. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69991. * This number is defined between 0 and 1;
  69992. */
  69993. mixToTile: number;
  69994. /**
  69995. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69996. * This number is defined between 0 and 1;
  69997. */
  69998. mixToNormal: number;
  69999. /**
  70000. * Instantiates a new Digital Rain Post Process.
  70001. * @param name the name to give to the postprocess
  70002. * @camera the camera to apply the post process to.
  70003. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70004. */
  70005. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70006. }
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var oceanPostProcessPixelShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. /**
  70017. * Option available in the Ocean Post Process.
  70018. */
  70019. export interface IOceanPostProcessOptions {
  70020. /**
  70021. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70022. */
  70023. reflectionSize?: number | {
  70024. width: number;
  70025. height: number;
  70026. } | {
  70027. ratio: number;
  70028. };
  70029. /**
  70030. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70031. */
  70032. refractionSize?: number | {
  70033. width: number;
  70034. height: number;
  70035. } | {
  70036. ratio: number;
  70037. };
  70038. }
  70039. /**
  70040. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70041. *
  70042. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70043. * Example usage:
  70044. * var pp = new OceanPostProcess("myOcean", camera);
  70045. * pp.reflectionEnabled = true;
  70046. * pp.refractionEnabled = true;
  70047. */
  70048. export class OceanPostProcess extends BABYLON.PostProcess {
  70049. /**
  70050. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70051. */
  70052. /**
  70053. * Sets weither or not the real-time reflection is enabled on the ocean.
  70054. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70055. */
  70056. reflectionEnabled: boolean;
  70057. /**
  70058. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70059. */
  70060. /**
  70061. * Sets weither or not the real-time refraction is enabled on the ocean.
  70062. * Is set to true, the refraction render target texture will be used as refraction texture.
  70063. */
  70064. refractionEnabled: boolean;
  70065. /**
  70066. * Gets wether or not the post-processes is supported by the running hardware.
  70067. * This requires draw buffer supports.
  70068. */
  70069. readonly isSupported: boolean;
  70070. /**
  70071. * This is the reflection mirror texture used to display reflections on the ocean.
  70072. * By default, render list is empty.
  70073. */
  70074. reflectionTexture: BABYLON.MirrorTexture;
  70075. /**
  70076. * This is the refraction render target texture used to display refraction on the ocean.
  70077. * By default, render list is empty.
  70078. */
  70079. refractionTexture: BABYLON.RenderTargetTexture;
  70080. private _time;
  70081. private _cameraRotation;
  70082. private _cameraViewMatrix;
  70083. private _reflectionEnabled;
  70084. private _refractionEnabled;
  70085. private _geometryRenderer;
  70086. /**
  70087. * Instantiates a new Ocean Post Process.
  70088. * @param name the name to give to the postprocess.
  70089. * @camera the camera to apply the post process to.
  70090. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70091. */
  70092. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70093. /**
  70094. * Returns the appropriate defines according to the current configuration.
  70095. */
  70096. private _getDefines;
  70097. /**
  70098. * Computes the current camera rotation as the shader requires a camera rotation.
  70099. */
  70100. private _computeCameraRotation;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /** @hidden */
  70105. export var brickProceduralTexturePixelShader: {
  70106. name: string;
  70107. shader: string;
  70108. };
  70109. }
  70110. declare module BABYLON {
  70111. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70112. private _numberOfBricksHeight;
  70113. private _numberOfBricksWidth;
  70114. private _jointColor;
  70115. private _brickColor;
  70116. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70117. updateShaderUniforms(): void;
  70118. numberOfBricksHeight: number;
  70119. numberOfBricksWidth: number;
  70120. jointColor: BABYLON.Color3;
  70121. brickColor: BABYLON.Color3;
  70122. /**
  70123. * Serializes this brick procedural texture
  70124. * @returns a serialized brick procedural texture object
  70125. */
  70126. serialize(): any;
  70127. /**
  70128. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70129. * @param parsedTexture defines parsed texture data
  70130. * @param scene defines the current scene
  70131. * @param rootUrl defines the root URL containing brick procedural texture information
  70132. * @returns a parsed Brick Procedural BABYLON.Texture
  70133. */
  70134. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70135. }
  70136. }
  70137. declare module BABYLON {
  70138. /** @hidden */
  70139. export var cloudProceduralTexturePixelShader: {
  70140. name: string;
  70141. shader: string;
  70142. };
  70143. }
  70144. declare module BABYLON {
  70145. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70146. private _skyColor;
  70147. private _cloudColor;
  70148. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70149. updateShaderUniforms(): void;
  70150. skyColor: BABYLON.Color4;
  70151. cloudColor: BABYLON.Color4;
  70152. /**
  70153. * Serializes this cloud procedural texture
  70154. * @returns a serialized cloud procedural texture object
  70155. */
  70156. serialize(): any;
  70157. /**
  70158. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70159. * @param parsedTexture defines parsed texture data
  70160. * @param scene defines the current scene
  70161. * @param rootUrl defines the root URL containing cloud procedural texture information
  70162. * @returns a parsed Cloud Procedural BABYLON.Texture
  70163. */
  70164. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70165. }
  70166. }
  70167. declare module BABYLON {
  70168. /** @hidden */
  70169. export var fireProceduralTexturePixelShader: {
  70170. name: string;
  70171. shader: string;
  70172. };
  70173. }
  70174. declare module BABYLON {
  70175. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70176. private _time;
  70177. private _speed;
  70178. private _autoGenerateTime;
  70179. private _fireColors;
  70180. private _alphaThreshold;
  70181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70182. updateShaderUniforms(): void;
  70183. render(useCameraPostProcess?: boolean): void;
  70184. static readonly PurpleFireColors: BABYLON.Color3[];
  70185. static readonly GreenFireColors: BABYLON.Color3[];
  70186. static readonly RedFireColors: BABYLON.Color3[];
  70187. static readonly BlueFireColors: BABYLON.Color3[];
  70188. autoGenerateTime: boolean;
  70189. fireColors: BABYLON.Color3[];
  70190. time: number;
  70191. speed: BABYLON.Vector2;
  70192. alphaThreshold: number;
  70193. /**
  70194. * Serializes this fire procedural texture
  70195. * @returns a serialized fire procedural texture object
  70196. */
  70197. serialize(): any;
  70198. /**
  70199. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70200. * @param parsedTexture defines parsed texture data
  70201. * @param scene defines the current scene
  70202. * @param rootUrl defines the root URL containing fire procedural texture information
  70203. * @returns a parsed Fire Procedural BABYLON.Texture
  70204. */
  70205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70206. }
  70207. }
  70208. declare module BABYLON {
  70209. /** @hidden */
  70210. export var grassProceduralTexturePixelShader: {
  70211. name: string;
  70212. shader: string;
  70213. };
  70214. }
  70215. declare module BABYLON {
  70216. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70217. private _grassColors;
  70218. private _groundColor;
  70219. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70220. updateShaderUniforms(): void;
  70221. grassColors: BABYLON.Color3[];
  70222. groundColor: BABYLON.Color3;
  70223. /**
  70224. * Serializes this grass procedural texture
  70225. * @returns a serialized grass procedural texture object
  70226. */
  70227. serialize(): any;
  70228. /**
  70229. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70230. * @param parsedTexture defines parsed texture data
  70231. * @param scene defines the current scene
  70232. * @param rootUrl defines the root URL containing grass procedural texture information
  70233. * @returns a parsed Grass Procedural BABYLON.Texture
  70234. */
  70235. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70236. }
  70237. }
  70238. declare module BABYLON {
  70239. /** @hidden */
  70240. export var marbleProceduralTexturePixelShader: {
  70241. name: string;
  70242. shader: string;
  70243. };
  70244. }
  70245. declare module BABYLON {
  70246. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70247. private _numberOfTilesHeight;
  70248. private _numberOfTilesWidth;
  70249. private _amplitude;
  70250. private _jointColor;
  70251. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70252. updateShaderUniforms(): void;
  70253. numberOfTilesHeight: number;
  70254. amplitude: number;
  70255. numberOfTilesWidth: number;
  70256. jointColor: BABYLON.Color3;
  70257. /**
  70258. * Serializes this marble procedural texture
  70259. * @returns a serialized marble procedural texture object
  70260. */
  70261. serialize(): any;
  70262. /**
  70263. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70264. * @param parsedTexture defines parsed texture data
  70265. * @param scene defines the current scene
  70266. * @param rootUrl defines the root URL containing marble procedural texture information
  70267. * @returns a parsed Marble Procedural BABYLON.Texture
  70268. */
  70269. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export var normalMapProceduralTexturePixelShader: {
  70275. name: string;
  70276. shader: string;
  70277. };
  70278. }
  70279. declare module BABYLON {
  70280. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70281. private _baseTexture;
  70282. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70283. updateShaderUniforms(): void;
  70284. render(useCameraPostProcess?: boolean): void;
  70285. resize(size: any, generateMipMaps: any): void;
  70286. baseTexture: BABYLON.Texture;
  70287. /**
  70288. * Serializes this normal map procedural texture
  70289. * @returns a serialized normal map procedural texture object
  70290. */
  70291. serialize(): any;
  70292. /**
  70293. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70294. * @param parsedTexture defines parsed texture data
  70295. * @param scene defines the current scene
  70296. * @param rootUrl defines the root URL containing normal map procedural texture information
  70297. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70298. */
  70299. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70300. }
  70301. }
  70302. declare module BABYLON {
  70303. /** @hidden */
  70304. export var perlinNoiseProceduralTexturePixelShader: {
  70305. name: string;
  70306. shader: string;
  70307. };
  70308. }
  70309. declare module BABYLON {
  70310. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70311. time: number;
  70312. timeScale: number;
  70313. translationSpeed: number;
  70314. private _currentTranslation;
  70315. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70316. updateShaderUniforms(): void;
  70317. render(useCameraPostProcess?: boolean): void;
  70318. resize(size: any, generateMipMaps: any): void;
  70319. /**
  70320. * Serializes this perlin noise procedural texture
  70321. * @returns a serialized perlin noise procedural texture object
  70322. */
  70323. serialize(): any;
  70324. /**
  70325. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70326. * @param parsedTexture defines parsed texture data
  70327. * @param scene defines the current scene
  70328. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70329. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70330. */
  70331. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70332. }
  70333. }
  70334. declare module BABYLON {
  70335. /** @hidden */
  70336. export var roadProceduralTexturePixelShader: {
  70337. name: string;
  70338. shader: string;
  70339. };
  70340. }
  70341. declare module BABYLON {
  70342. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70343. private _roadColor;
  70344. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70345. updateShaderUniforms(): void;
  70346. roadColor: BABYLON.Color3;
  70347. /**
  70348. * Serializes this road procedural texture
  70349. * @returns a serialized road procedural texture object
  70350. */
  70351. serialize(): any;
  70352. /**
  70353. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70354. * @param parsedTexture defines parsed texture data
  70355. * @param scene defines the current scene
  70356. * @param rootUrl defines the root URL containing road procedural texture information
  70357. * @returns a parsed Road Procedural BABYLON.Texture
  70358. */
  70359. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /** @hidden */
  70364. export var starfieldProceduralTexturePixelShader: {
  70365. name: string;
  70366. shader: string;
  70367. };
  70368. }
  70369. declare module BABYLON {
  70370. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70371. private _time;
  70372. private _alpha;
  70373. private _beta;
  70374. private _zoom;
  70375. private _formuparam;
  70376. private _stepsize;
  70377. private _tile;
  70378. private _brightness;
  70379. private _darkmatter;
  70380. private _distfading;
  70381. private _saturation;
  70382. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70383. updateShaderUniforms(): void;
  70384. time: number;
  70385. alpha: number;
  70386. beta: number;
  70387. formuparam: number;
  70388. stepsize: number;
  70389. zoom: number;
  70390. tile: number;
  70391. brightness: number;
  70392. darkmatter: number;
  70393. distfading: number;
  70394. saturation: number;
  70395. /**
  70396. * Serializes this starfield procedural texture
  70397. * @returns a serialized starfield procedural texture object
  70398. */
  70399. serialize(): any;
  70400. /**
  70401. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70402. * @param parsedTexture defines parsed texture data
  70403. * @param scene defines the current scene
  70404. * @param rootUrl defines the root URL containing startfield procedural texture information
  70405. * @returns a parsed Starfield Procedural BABYLON.Texture
  70406. */
  70407. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70408. }
  70409. }
  70410. declare module BABYLON {
  70411. /** @hidden */
  70412. export var woodProceduralTexturePixelShader: {
  70413. name: string;
  70414. shader: string;
  70415. };
  70416. }
  70417. declare module BABYLON {
  70418. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70419. private _ampScale;
  70420. private _woodColor;
  70421. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70422. updateShaderUniforms(): void;
  70423. ampScale: number;
  70424. woodColor: BABYLON.Color3;
  70425. /**
  70426. * Serializes this wood procedural texture
  70427. * @returns a serialized wood procedural texture object
  70428. */
  70429. serialize(): any;
  70430. /**
  70431. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70432. * @param parsedTexture defines parsed texture data
  70433. * @param scene defines the current scene
  70434. * @param rootUrl defines the root URL containing wood procedural texture information
  70435. * @returns a parsed Wood Procedural BABYLON.Texture
  70436. */
  70437. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70438. }
  70439. }